Skip to content

Commit

Permalink
Fix style due to new black version
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed May 1, 2018
1 parent e6cd482 commit d02f24a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 17 deletions.
4 changes: 3 additions & 1 deletion pythonscript/embedded/godot/hazmat/ffi/editor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from pythonscriptcffi import ffi, lib

from godot.hazmat.tools import (
godot_string_to_pyobj, godot_string_from_pyobj_for_ffi_return, variant_to_pyobj
godot_string_to_pyobj,
godot_string_from_pyobj_for_ffi_return,
variant_to_pyobj,
)
from godot.bindings import PoolStringArray
import godot.globals
Expand Down
4 changes: 3 additions & 1 deletion pythonscript/embedded/godot/hazmat/ffi/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from godot.hazmat.base import BaseObject, get_exposed_class_per_module
from godot.hazmat.gc_protector import connect_handle
from godot.hazmat.tools import (
godot_string_to_pyobj, godot_string_from_pyobj, py_to_gd_type
godot_string_to_pyobj,
godot_string_from_pyobj,
py_to_gd_type,
)
from godot.bindings import Dictionary, Array

Expand Down
8 changes: 6 additions & 2 deletions pythonscript/embedded/godot/hazmat/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,16 @@ def variant_to_pyobj(p_gdvar):
elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_VECTOR2_ARRAY:
p_raw = godot_pool_vector2_array_alloc(initialized=False)
p_raw[0] = lib.godot_variant_as_pool_vector2_array(p_gdvar)
return godot_bindings_module.PoolVector2Array.build_from_gdobj(p_raw, steal=True)
return godot_bindings_module.PoolVector2Array.build_from_gdobj(
p_raw, steal=True
)

elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_VECTOR3_ARRAY:
p_raw = godot_pool_vector3_array_alloc(initialized=False)
p_raw[0] = lib.godot_variant_as_pool_vector3_array(p_gdvar)
return godot_bindings_module.PoolVector3Array.build_from_gdobj(p_raw, steal=True)
return godot_bindings_module.PoolVector3Array.build_from_gdobj(
p_raw, steal=True
)

elif gdtype == lib.GODOT_VARIANT_TYPE_POOL_COLOR_ARRAY:
p_raw = godot_pool_color_array_alloc(initialized=False)
Expand Down
10 changes: 5 additions & 5 deletions tests/bindings/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def test_delitem(self):
del v[object()]

def test_update(self):
v = Dictionary({'a': 1, 'b': 2, 'c': 3})
v.update({'a': 'one', 'd': 'four'})
v.update(Dictionary({'b': 'two', 'e': 'five'}))
assert set(v.keys()) == {'a', 'b', 'c', 'd', 'e'}
assert set(v.values()) == {'one', 'two', 3, 'four', 'five'}
v = Dictionary({"a": 1, "b": 2, "c": 3})
v.update({"a": "one", "d": "four"})
v.update(Dictionary({"b": "two", "e": "five"}))
assert set(v.keys()) == {"a", "b", "c", "d", "e"}
assert set(v.values()) == {"one", "two", 3, "four", "five"}

def test_contains(self):
v = Dictionary({"a": 1, 2: "foo", 0.5: Vector2()})
Expand Down
11 changes: 10 additions & 1 deletion tests/bindings/test_dynamic_bindings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import pytest

from godot.bindings import (
Object, Node, Viewport, Input, LineEdit, Engine, _Engine, KEY_ESCAPE, OK, FAILED
Object,
Node,
Viewport,
Input,
LineEdit,
Engine,
_Engine,
KEY_ESCAPE,
OK,
FAILED,
)


Expand Down
16 changes: 11 additions & 5 deletions tests/bindings/test_memory_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_base_dynamic_memory_leak_check():


def test_base_builtin_memory_leak():

def fn():
v = bindings.Vector3()
v.x = 42
Expand All @@ -51,21 +52,23 @@ def fn():


def test_dictionary_memory_leak():

def fn():
v = bindings.Dictionary()
v['foo'] = OS
v.update({'a': 1, 'b': 2.0, 'c': 'three'})
v['foo']
v["foo"] = OS
v.update({"a": 1, "b": 2.0, "c": "three"})
v["foo"]
[x for x in v.items()]
del v['a']
del v["a"]

check_memory_leak(fn)


def test_array_memory_leak():

def fn():
v = bindings.Array()
v.append('x')
v.append("x")
v += [1, 2, 3]
v[0]
[x for x in v]
Expand All @@ -74,6 +77,7 @@ def fn():


def test_pool_int_array_memory_leak():

def fn():
v = bindings.PoolIntArray()
v.append(42)
Expand All @@ -84,6 +88,7 @@ def fn():


def test_pool_string_array_memory_leak():

def fn():
v = bindings.PoolStringArray()
v.append("fooo")
Expand All @@ -94,6 +99,7 @@ def fn():


def test_object_memory_leak():

def fn():
v = bindings.Node()
v.free()
Expand Down
1 change: 0 additions & 1 deletion tests/bindings/test_pool_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_add_with_non_PoolBytearray(self):
arr4 = [values[0]] + list(pba)
assert arr4 == values


@pytest.mark.parametrize("arg", [None, 0, "foo", Vector2(), Node()])
def test_bad_add(self, arg):
with pytest.raises(TypeError):
Expand Down
2 changes: 1 addition & 1 deletion tools/multi_platform_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def fetch_build(src, version, target):
urlretrieve(
url,
filename=build_zipname,
reporthook=lambda *args: print(".", end="", flush=True)
reporthook=lambda *args: print(".", end="", flush=True),
)
return ZipFile(cache_file)

Expand Down

0 comments on commit d02f24a

Please sign in to comment.