diff --git a/bench/basic_micro.py b/bench/basic_micro.py index 712cac13..f7ac3a99 100644 --- a/bench/basic_micro.py +++ b/bench/basic_micro.py @@ -1,4 +1,9 @@ -import cppyy, gc, math, os, psutil, time +import cppyy +import gc +import math +import os +import psutil +import time NLARGE = 20000000 diff --git a/bench/bench_functioncalls.py b/bench/bench_functioncalls.py index 23c51d96..9424a1cd 100644 --- a/bench/bench_functioncalls.py +++ b/bench/bench_functioncalls.py @@ -1,4 +1,5 @@ -import py, pytest, os, sys, math, warnings +import sys +import warnings from support import setup_make setup_make("functioncallsDict.so") @@ -9,7 +10,6 @@ cppyy.load_library("functioncalls") cppyy.load_library("functioncallsDict") -import py_functioncalls all_configs = [('py', 'py_functioncalls'), ('cppyy', 'cppyy.gbl')] diff --git a/bench/bench_runvector.py b/bench/bench_runvector.py index f6444922..60144f67 100644 --- a/bench/bench_runvector.py +++ b/bench/bench_runvector.py @@ -1,4 +1,4 @@ -import py, pytest, os, sys, math, warnings +import warnings from support import setup_make setup_make("runvectorDict.so") diff --git a/bench/py_runvector.py b/bench/py_runvector.py index e1f3649a..b384b7a1 100644 --- a/bench/py_runvector.py +++ b/bench/py_runvector.py @@ -1,4 +1,5 @@ -import array, sys +import array +import sys N = 100000000 # 10^8 diff --git a/bench/support.py b/bench/support.py index a2eeeaf2..d5a290c8 100644 --- a/bench/support.py +++ b/bench/support.py @@ -1,5 +1,7 @@ from __future__ import print_function -import py, sys, subprocess +import py +import sys +import subprocess currpath = py.path.local(__file__).dirpath() diff --git a/doc/source/conf.py b/doc/source/conf.py index 96204711..c0c39015 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,9 +12,6 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys -import os -import shlex # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/doc/tutorial/GSLPythonizationTutorial.ipynb b/doc/tutorial/GSLPythonizationTutorial.ipynb index 58cf576c..90c4d1a5 100644 --- a/doc/tutorial/GSLPythonizationTutorial.ipynb +++ b/doc/tutorial/GSLPythonizationTutorial.ipynb @@ -47,7 +47,8 @@ "outputs": [], "source": [ "# first, pull in all headers from the GSL installation directory (/usr/include on my system).\n", - "import glob, os\n", + "import glob\n", + "import os\n", "GSL_HOME = '/usr/include'\n", "gsl_headers = [os.path.relpath(x, GSL_HOME) for x in glob.glob(GSL_HOME+'/gsl/*.h')]" ] @@ -100,7 +101,7 @@ "rfldct = 'GSLDict'\n", "\n", "if not os.path.exists('%s_rflx.cpp' % rfldct):\n", - " import subprocess, sys\n", + " import subprocess\n", "\n", " # generate the reflection dictionary\n", " try:\n", diff --git a/python/cppyy/__init__.py b/python/cppyy/__init__.py index dc00b0d6..c61229f1 100644 --- a/python/cppyy/__init__.py +++ b/python/cppyy/__init__.py @@ -51,9 +51,13 @@ from ._version import __version__ -import ctypes, os, sys, sysconfig, warnings +import ctypes +import os +import sys +import sysconfig +import warnings -if not 'CLING_STANDARD_PCH' in os.environ: +if 'CLING_STANDARD_PCH' not in os.environ: def _set_pch(): try: import cppyy_backend as cpb @@ -177,7 +181,7 @@ def __getitem__(self, cls): return py_make_smartptr(cls, self.ptrcls) except AttributeError: pass - if type(cls) == str and not cls in ('int', 'float'): + if type(cls) == str and cls not in ('int', 'float'): return py_make_smartptr(getattr(gbl, cls), self.ptrcls) return self.maker[cls] @@ -206,7 +210,7 @@ def cppdef(src): with _stderr_capture() as err: errcode = gbl.Cpp.Declare(src) if not errcode == 0 or err.err: - if 'warning' in err.err.lower() and not 'error' in err.err.lower(): + if 'warning' in err.err.lower() and 'error' not in err.err.lower(): warnings.warn(err.err, SyntaxWarning) return True raise SyntaxError('Failed to parse the given C++ code%s' % err.err) @@ -316,7 +320,8 @@ def add_library_path(path): apipath_extra = os.path.join(os.path.dirname(apipath), 'site', 'python'+ldversion) if not os.path.exists(os.path.join(apipath_extra, 'CPyCppyy')): - import glob, libcppyy + import glob + import libcppyy ape = os.path.dirname(libcppyy.__file__) # a "normal" structure finds the include directory up to 3 levels up, # ie. dropping lib/pythonx.y[md]/site-packages diff --git a/python/cppyy/__pyinstaller/hook-cppyy.py b/python/cppyy/__pyinstaller/hook-cppyy.py index 3c542a88..bf0de361 100644 --- a/python/cppyy/__pyinstaller/hook-cppyy.py +++ b/python/cppyy/__pyinstaller/hook-cppyy.py @@ -8,7 +8,9 @@ def _backend_files(): - import cppyy_backend, glob, os + import cppyy_backend + import glob + import os all_files = glob.glob(os.path.join( os.path.dirname(cppyy_backend.__file__), '*')) @@ -19,7 +21,8 @@ def datafile(path): return [datafile(filename) for filename in all_files if os.path.isdir(filename)] def _api_files(): - import cppyy, os + import cppyy + import os # FIXME: We should add an interface in InterOp. paths = str(cppyy.gbl.runtime.gCling.GetIncludePath()).split('-I') diff --git a/python/cppyy/_cpython_cppyy.py b/python/cppyy/_cpython_cppyy.py index c26a86c4..46795348 100644 --- a/python/cppyy/_cpython_cppyy.py +++ b/python/cppyy/_cpython_cppyy.py @@ -1,7 +1,6 @@ """ CPython-specific touch-ups """ -from . import _stdcpp_fix from cppyy_backend import loader __all__ = [ @@ -92,7 +91,7 @@ def __getitem__(self, *args): self._instantiations[args] = pyclass # special case pythonization (builtin_map is not available from the C-API) - if 'push_back' in pyclass.__dict__ and not '__iadd__' in pyclass.__dict__: + if 'push_back' in pyclass.__dict__ and '__iadd__' not in pyclass.__dict__: if 'reserve' in pyclass.__dict__: def iadd(self, ll): self.reserve(len(ll)) @@ -196,7 +195,7 @@ def load_reflection_info(name): name = name + ".so" result = CppInterOp.LoadLibrary(name) if name.endswith("Dict.so"): - header = name[:-7] + ".h"; + header = name[:-7] + ".h" CppInterOp.Declare('#include "' + header +'"') if result == False: diff --git a/python/cppyy/_pypy_cppyy.py b/python/cppyy/_pypy_cppyy.py index 78ad08a1..fb4bc773 100644 --- a/python/cppyy/_pypy_cppyy.py +++ b/python/cppyy/_pypy_cppyy.py @@ -1,9 +1,9 @@ """ PyPy-specific touch-ups """ -from . import _stdcpp_fix -import os, sys +import os +import sys from cppyy_backend import loader __all__ = [ @@ -46,7 +46,6 @@ def fixup_legacy(): #- exports ------------------------------------------------------------------- -import sys _thismodule = sys.modules[__name__] for name in __all__: try: diff --git a/python/cppyy/_typemap.py b/python/cppyy/_typemap.py index 3aefbf4e..fe4807fd 100644 --- a/python/cppyy/_typemap.py +++ b/python/cppyy/_typemap.py @@ -101,7 +101,8 @@ def initialize(backend): # void* import ctypes def voidp_init(self, arg=0): - import cppyy, ctypes + import cppyy + import ctypes if arg == cppyy.nullptr: arg = 0 ctypes.c_void_p.__init__(self, arg) tm['void*'] = _create_mapper(ctypes.c_void_p, {'__init__' : voidp_init}) diff --git a/python/cppyy/interactive.py b/python/cppyy/interactive.py index a9be6c3e..fda94834 100644 --- a/python/cppyy/interactive.py +++ b/python/cppyy/interactive.py @@ -13,7 +13,8 @@ def __init__(self, hook_okay): self._hook_okay = hook_okay def __getattr__(self, attr): - import cppyy, sys + import cppyy + import sys if attr == '__all__': # copy all exported items from cppyy itself for v in cppyy.__all__: diff --git a/python/cppyy/numba_ext.py b/python/cppyy/numba_ext.py index da860027..9e036c20 100644 --- a/python/cppyy/numba_ext.py +++ b/python/cppyy/numba_ext.py @@ -5,7 +5,6 @@ import cppyy.types as cpp_types import cppyy.reflex as cpp_refl -import numba import numba.extending as nb_ext import numba.core.cgutils as nb_cgu import numba.core.datamodel as nb_dm diff --git a/python/cppyy_compat/__init__.py b/python/cppyy_compat/__init__.py index d9d36055..90da030c 100644 --- a/python/cppyy_compat/__init__.py +++ b/python/cppyy_compat/__init__.py @@ -2,10 +2,11 @@ """ def pypy58_57_compat(): - import imp, os + import imp + import os # first load and move the builtin cppyy module - if not 'cppyy' in sys.modules: + if 'cppyy' not in sys.modules: try: olddir = os.getcwd() from cppyy_backend import loader @@ -43,7 +44,8 @@ def pypy58_57_compat(): # for pypy5.9 we may need to move to the location of the backend, if '.' happens # to be in LD_LIBRARY_PATH, but not the full directory def py59_compat(): - import os, cppyy_backend + import os + import cppyy_backend olddir = os.getcwd() c = cppyy_backend.loader.load_cpp_backend() os.chdir(os.path.dirname(c._name)) diff --git a/setup.py b/setup.py index 28f856b7..0cfe1aea 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,8 @@ -import codecs, glob, os, sys, re -from setuptools import setup, find_packages, Extension +import codecs +import os +import sys +import re +from setuptools import setup, find_packages from distutils import log from setuptools.command.install import install as _install diff --git a/test/bindexplib.py b/test/bindexplib.py index 838dca4d..6e385727 100755 --- a/test/bindexplib.py +++ b/test/bindexplib.py @@ -1,13 +1,14 @@ from __future__ import print_function -import os, sys, subprocess +import sys +import subprocess target = sys.argv[1] output = sys.argv[2] def isokay(name): # filter standard symbols - return name[0] != '_' and not name in {'memcpy', 'memmove', 'memset'} + return name[0] != '_' and name not in {'memcpy', 'memmove', 'memset'} popen = subprocess.Popen(['dumpbin', '/SYMBOLS', target+'.obj'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) diff --git a/test/make_dict_win32.py b/test/make_dict_win32.py index 6837f6b0..36cbcb9e 100755 --- a/test/make_dict_win32.py +++ b/test/make_dict_win32.py @@ -1,4 +1,7 @@ -import glob, os, sys, subprocess +import glob +import os +import sys +import subprocess USES_PYTHON_CAPI = set(('pythonizables',)) @@ -24,7 +27,7 @@ if os.path.exists(fn+'Dict.dll'): dct_time = os.stat(fn+'Dict.dll').st_mtime - if not '-f' in sys.argv: + if '-f' not in sys.argv: mustbuild = False for ext in ['.h', '.cxx', '.xml']: if os.stat(fn+ext).st_mtime > dct_time: @@ -86,7 +89,6 @@ def get_python_lib_dir(): if os.system(BUILDOBJ_CMD): sys.exit(1) -import cppyy_backend CREATEDEF_CMD = "python bindexplib.py {fn} {fn}Dict".format(fn=fn) if os.system(CREATEDEF_CMD): sys.exit(1) diff --git a/test/support.py b/test/support.py index b69ca309..7e29dd85 100644 --- a/test/support.py +++ b/test/support.py @@ -1,5 +1,8 @@ from __future__ import print_function -import os, py, sys, subprocess +import os +import py +import sys +import subprocess currpath = py.path.local(__file__).dirpath() diff --git a/test/test_aclassloader.py b/test/test_aclassloader.py index 16c21176..4a4efdc6 100644 --- a/test/test_aclassloader.py +++ b/test/test_aclassloader.py @@ -1,5 +1,4 @@ -import py, os, sys -from pytest import raises, mark +import py from .support import setup_make currpath = py.path.local(__file__).dirpath() diff --git a/test/test_advancedcpp.py b/test/test_advancedcpp.py index 623452da..57be5ee3 100644 --- a/test/test_advancedcpp.py +++ b/test/test_advancedcpp.py @@ -1,6 +1,6 @@ -import py, os, sys +import py from pytest import raises, skip, mark -from .support import setup_make, pylong, IS_WINDOWS, IS_MAC, IS_LINUX, ispypy, IS_CLANG_REPL, IS_MAC_ARM, IS_MAC_X86 +from .support import setup_make, pylong, IS_WINDOWS, IS_MAC, ispypy, IS_CLANG_REPL, IS_MAC_ARM currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("advancedcppDict")) @@ -192,8 +192,8 @@ def test04_template_types(self): assert gbl.T1 is gbl.T1 assert gbl.T2 is gbl.T2 assert gbl.T3 is gbl.T3 - assert not gbl.T1 is gbl.T2 - assert not gbl.T2 is gbl.T3 + assert gbl.T1 is not gbl.T2 + assert gbl.T2 is not gbl.T3 assert gbl.T1('int') is gbl.T1('int') assert gbl.T1(int) is gbl.T1('int') @@ -472,19 +472,19 @@ def test10_object_identity(self): assert o is o2 o3 = cppyy.bind_object(addr, some_class_with_data) - assert not o is o3 + assert o is not o3 d1 = some_class_with_data() d2 = d1.gime_copy() - assert not d1 is d2 + assert d1 is not d2 dd1a = d1.gime_data() dd1b = d1.gime_data() assert dd1a is dd1b dd2 = d2.gime_data() - assert not dd1a is dd2 - assert not dd1b is dd2 + assert dd1a is not dd2 + assert dd1b is not dd2 d2.__destruct__() d1.__destruct__() @@ -568,7 +568,7 @@ def test12_actual_type(self): b1 = cppyy.bind_object(voidp, base_class) assert isinstance(b1, base_class) assert cppyy.addressof(b1) == cppyy.addressof(d) - assert not (b1 is d) + assert b1 is not d def test13_actual_type_virtual_multi(self): """Test auto-downcast in adverse inheritance situation""" @@ -754,7 +754,7 @@ def test23_using(self): assert cppyy.gbl.UsingBase1().vcheck() == 'A' D1 = cppyy.gbl.UsingDerived1 - assert not 'UsingBase1' in D1.__init__.__doc__ + assert 'UsingBase1' not in D1.__init__.__doc__ d1a = D1() assert d1a.m_int == 13 diff --git a/test/test_api.py b/test/test_api.py index 24509945..107eaf3e 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -1,5 +1,4 @@ -import py, os, sys -from pytest import raises, skip, mark +from pytest import skip, mark from .support import ispypy, IS_MAC, IS_LINUX_ARM @@ -188,7 +187,7 @@ class APICheck4Executor : public CPyCppyy::Executor { a4 = cppyy.gbl.CreateAPICheck4() assert a4 assert type(a4) == cppyy.gbl.APICheck4 - assert a4.wasExecutorCalled(); + assert a4.wasExecutorCalled() del a4 cppyy.gbl.unregister_a4() @@ -196,4 +195,4 @@ class APICheck4Executor : public CPyCppyy::Executor { a4 = cppyy.gbl.CreateAPICheck4b() assert a4 assert type(a4) == cppyy.gbl.APICheck4 - assert not a4.wasExecutorCalled(); + assert not a4.wasExecutorCalled() diff --git a/test/test_boost.py b/test/test_boost.py index a3eb38f1..92f1496d 100644 --- a/test/test_boost.py +++ b/test/test_boost.py @@ -1,6 +1,6 @@ -import py, os, sys +import os from pytest import mark, raises, skip -from .support import setup_make, IS_CLANG_REPL, IS_MAC_X86, IS_MAC_ARM +from .support import IS_MAC_X86, IS_MAC_ARM noboost = False if not (os.path.exists(os.path.join(os.path.sep, 'usr', 'include', 'boost')) or \ diff --git a/test/test_concurrent.py b/test/test_concurrent.py index 5d74d0cd..78a933d9 100644 --- a/test/test_concurrent.py +++ b/test/test_concurrent.py @@ -1,5 +1,4 @@ -import py, os, sys -from pytest import raises, skip, mark +from pytest import skip, mark from .support import IS_MAC_ARM, IS_MAC_X86, IS_LINUX_ARM @@ -59,7 +58,8 @@ def test03_timeout(self): return import cppyy - import threading, time + import threading + import time cppyy.cppdef("""\ namespace test12_timeout { diff --git a/test/test_conversions.py b/test/test_conversions.py index c9783df2..7d7512f8 100644 --- a/test/test_conversions.py +++ b/test/test_conversions.py @@ -1,6 +1,6 @@ -import py, os, sys +import py from pytest import raises, mark -from .support import setup_make, IS_LINUX, IS_CLANG_REPL, IS_CLING, IS_MAC +from .support import setup_make, IS_LINUX, IS_CLING, IS_MAC currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("conversionsDict")) @@ -42,7 +42,8 @@ def test01_implicit_vector_conversions(self): def test02_memory_handling_of_temporaries(self): """Verify that memory of temporaries is properly cleaned up""" - import cppyy, gc + import cppyy + import gc CNS, CC = cppyy.gbl.CNS, cppyy.gbl.CNS.Counter assert CC.s_count == 0 @@ -63,7 +64,8 @@ def test02_memory_handling_of_temporaries(self): def test03_error_handling(self): """Verify error handling""" - import cppyy, gc + import cppyy + import gc CNS, CC = cppyy.gbl.CNS, cppyy.gbl.CNS.Counter N = 13 diff --git a/test/test_cpp11features.py b/test/test_cpp11features.py index f19299e4..008deb02 100644 --- a/test/test_cpp11features.py +++ b/test/test_cpp11features.py @@ -1,6 +1,7 @@ -import py, os, sys +import py +import sys from pytest import raises, mark -from .support import setup_make, ispypy, IS_CLANG_REPL, IS_LINUX_ARM, IS_LINUX, IS_MAC, IS_CLING +from .support import setup_make, ispypy, IS_LINUX_ARM, IS_LINUX, IS_CLING currpath = py.path.local(__file__).dirpath() @@ -148,7 +149,7 @@ def test05_unique_ptr_passing(self): """Ability to pass unique_ptr through unique_ptr""" from cppyy.gbl import std, TestSmartPtr, DerivedTestSmartPtr - from cppyy.gbl import move_unique_ptr, move_unique_ptr_derived + from cppyy.gbl import move_unique_ptr_derived from cppyy.gbl import create_TestSmartPtr_by_value import gc @@ -214,7 +215,8 @@ def test06_nullptr(self): def test07_move(self): """Move construction, assignment, and methods""" - import cppyy, gc + import cppyy + import gc def moveit(T): assert T.s_instance_counter == 0 @@ -361,7 +363,6 @@ def test10_optional(self): def test11_chrono(self): """Use of chrono and overloaded operator+""" - import cppyy from cppyy.gbl import std t = std.chrono.system_clock.now() - std.chrono.seconds(1) @@ -388,7 +389,6 @@ def test12_stdfunction(self): std::function FNCreateTestStructFunc() { return [](const FNTestStruct& t) { return t.t; }; } }""") - from cppyy.gbl import FunctionNS2 t = FunctionNS.FNTestStruct(27) f = FunctionNS.FNCreateTestStructFunc() @@ -397,7 +397,6 @@ def test12_stdfunction(self): def test13_stdhash(self): """Use of std::hash""" - import cppyy from cppyy.gbl import StructWithHash, StructWithoutHash for i in range(3): # to test effect of caching @@ -413,7 +412,7 @@ def test13_stdhash(self): def test14_shared_ptr_passing(self): """Ability to pass normal pointers through shared_ptr by value""" - from cppyy.gbl import std, TestSmartPtr, DerivedTestSmartPtr + from cppyy.gbl import TestSmartPtr, DerivedTestSmartPtr from cppyy.gbl import pass_shared_ptr import gc diff --git a/test/test_crossinheritance.py b/test/test_crossinheritance.py index 9bab6994..05ef9fbe 100644 --- a/test/test_crossinheritance.py +++ b/test/test_crossinheritance.py @@ -1,6 +1,7 @@ -import py, os, sys +import py +import os from pytest import raises, skip, mark -from .support import setup_make, pylong, IS_MAC_ARM, IS_MAC, IS_CLANG_REPL, IS_CLANG_DEBUG, IS_LINUX_ARM, IS_LINUX +from .support import setup_make, IS_MAC_ARM, IS_MAC, IS_CLANG_REPL, IS_CLANG_DEBUG, IS_LINUX_ARM, IS_LINUX currpath = py.path.local(__file__).dirpath() @@ -214,7 +215,6 @@ def __init__(self): def test07_templated_base(self): """Derive from a base class that is instantiated from a template""" - import cppyy from cppyy.gbl.CrossInheritance import TBase1, TDerived1, TBase1_I @@ -299,7 +299,8 @@ def get_value(self): def test10_python_in_templates(self): """Usage of Python derived objects in std::vector""" - import cppyy, gc + import cppyy + import gc CB = cppyy.gbl.CrossInheritance.CountableBase @@ -360,7 +361,7 @@ class Abstract { return ptr->some_imp(); } }""") - from cppyy.gbl import std, MakeSharedTest + from cppyy.gbl import std from cppyy.gbl.MakeSharedTest import Abstract, call_shared class PyDerived(Abstract): @@ -383,7 +384,8 @@ def some_imp(self): def test12a_counter_test(self): """Test countable base counting""" - import cppyy, gc + import cppyy + import gc std = cppyy.gbl.std CB = cppyy.gbl.CrossInheritance.CountableBase @@ -409,7 +411,8 @@ def call(self): def test12_python_shared_ptr_memory(self): """Usage of Python derived objects with std::shared_ptr""" - import cppyy, gc + import cppyy + import gc std = cppyy.gbl.std CB = cppyy.gbl.CrossInheritance.CountableBase @@ -436,7 +439,8 @@ def call(self): def test13_virtual_dtors_and_del(self): """Usage of virtual destructors and Python-side del.""" - import cppyy, warnings + import cppyy + import warnings cppyy.cppdef("""namespace VirtualDtor { class MyClass1 {}; // no virtual dtor ... @@ -489,7 +493,7 @@ def test14_protected_access(self): ns = cppyy.gbl.AccessProtected - assert not 'my_data' in ns.MyBase.__dict__ + assert 'my_data' not in ns.MyBase.__dict__ assert not hasattr(ns.MyBase(), 'my_data') class MyPyDerived(ns.MyBase): @@ -1158,7 +1162,8 @@ def __init__(self): def test26_no_default_ctor(self): """Make sure no default ctor is created if not viable""" - import cppyy, warnings + import cppyy + import warnings cppyy.cppdef("""namespace no_default_ctor { struct NoDefCtor1 { @@ -1405,7 +1410,8 @@ class PyDerived(ns.Base): def test31_object_rebind(self): """Usage of bind_object to cast with Python derived objects""" - import cppyy, gc + import cppyy + import gc ns = cppyy.gbl.CrossInheritance ns.build_component.__creates__ = True diff --git a/test/test_datatypes.py b/test/test_datatypes.py index 3315d9a8..eca30fc5 100644 --- a/test/test_datatypes.py +++ b/test/test_datatypes.py @@ -1,6 +1,7 @@ -import py, os, sys +import py +import sys from pytest import raises, skip, mark -from .support import setup_make, pylong, pyunicode, IS_CLANG_REPL, IS_CLING, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_LINUX +from .support import setup_make, pylong, pyunicode, IS_CLING, IS_MAC_X86, IS_MAC_ARM, IS_MAC IS_MAC = IS_MAC_X86 or IS_MAC_ARM @@ -341,7 +342,8 @@ def test02_instance_data_write_access(self): def test03_array_passing(self): """Test passing of array arguments""" - import cppyy, array, sys + import cppyy + import array CppyyTestData = cppyy.gbl.CppyyTestData c = CppyyTestData() @@ -380,7 +382,7 @@ def test03_array_passing(self): def test04_class_read_access(self): """Test read access to class public data and verify values""" - import cppyy, sys + import cppyy CppyyTestData = cppyy.gbl.CppyyTestData c = CppyyTestData() @@ -443,7 +445,7 @@ def test04_class_read_access(self): def test05_class_data_write_access(self): """Test write access to class public data and verify values""" - import cppyy, sys + import cppyy CppyyTestData = cppyy.gbl.CppyyTestData c = CppyyTestData() @@ -528,7 +530,7 @@ def test05_class_data_write_access(self): def test06_range_access(self): """Test the ranges of integer types""" - import cppyy, sys + import cppyy CppyyTestData = cppyy.gbl.CppyyTestData c = CppyyTestData() @@ -544,7 +546,7 @@ def test06_range_access(self): def test07_type_conversions(self): """Test conversions between builtin types""" - import cppyy, sys + import cppyy CppyyTestData = cppyy.gbl.CppyyTestData c = CppyyTestData() @@ -1237,7 +1239,9 @@ def null_test(null): def test25_byte_arrays(self): """Usage of unsigned char* as byte array and std::byte*""" - import array, cppyy, ctypes + import array + import cppyy + import ctypes buf = b'123456789' total = 0 @@ -1336,7 +1340,8 @@ def sum_in_python(i1, i2, i3): def test27_callable_passing(self): """Passing callables through function pointers""" - import cppyy, gc + import cppyy + import gc fdd = cppyy.gbl.call_double_double fii = cppyy.gbl.call_int_int @@ -1409,7 +1414,8 @@ def pyd(arg0, arg1): def test28_callable_through_function_passing(self): """Passing callables through std::function""" - import cppyy, gc + import cppyy + import gc fdd = cppyy.gbl.call_double_double_sf fii = cppyy.gbl.call_int_int_sf @@ -1482,7 +1488,8 @@ def pyd(arg0, arg1): def test29_std_function_life_lines(self): """Life lines to std::function data members""" - import cppyy, gc + import cppyy + import gc cppyy.cppdef("""\ namespace BoundMethod2StdFunction { @@ -1519,7 +1526,8 @@ def xyz(self): def test30_multi_dim_arrays_of_builtins(test): """Multi-dim arrays of builtins""" - import cppyy, ctypes + import cppyy + import ctypes cppyy.cppdef(""" template @@ -1794,11 +1802,11 @@ def test36_legacy_matrix(self): return true; } }""") - ns = cppyy.gbl.Pointer2D; + ns = cppyy.gbl.Pointer2D N, M = 2, 3 m = ns.create_matrix(N, M) - g = ns.g_matrix; + g = ns.g_matrix for i in range(N): for j in range(M): @@ -1852,11 +1860,11 @@ def test37_legacy_matrix_of_structs(self): return true; } }""") - ns = cppyy.gbl.StructPointer2D; + ns = cppyy.gbl.StructPointer2D N, M = 2, 3 m = ns.create_matrix(N, M) - g = ns.g_matrix; + g = ns.g_matrix assert (m.x, m.y) == (13, 7) assert (g.x, g.y) == (13, 7) @@ -2163,7 +2171,8 @@ def test43_ccharp_memory_handling(self): def test44_buffer_memory_handling(self): """cppyy side handled memory of LL buffers""" - import cppyy, gc + import cppyy + import gc try: import numpy as np except ImportError: diff --git a/test/test_doc_features.py b/test/test_doc_features.py index bdecdf3e..18e7d07f 100644 --- a/test/test_doc_features.py +++ b/test/test_doc_features.py @@ -1,6 +1,7 @@ -import py, os, sys +import py +import sys from pytest import raises, skip, mark -from .support import setup_make, ispypy, IS_WINDOWS, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC, IS_MAC_X86, IS_MAC_ARM, IS_LINUX_ARM +from .support import setup_make, ispypy, IS_WINDOWS, IS_CLANG_REPL, IS_CLING, IS_MAC, IS_MAC_ARM, IS_LINUX_ARM currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("doc_helperDict")) @@ -163,7 +164,6 @@ class NestedClass { """) def test_abstract_class(self): - import cppyy from cppyy.gbl import Abstract, Concrete raises(TypeError, Abstract) @@ -172,7 +172,6 @@ def test_abstract_class(self): assert isinstance(c, Abstract) def test_array(self): - import cppyy from cppyy.gbl import Concrete from array import array @@ -200,7 +199,6 @@ def test_casting(self): assert type(e) == cppyy.gbl.Abstract def test_classes_and_structs(self): - import cppyy from cppyy.gbl import Concrete, Namespace assert Concrete != Namespace.Concrete @@ -211,7 +209,6 @@ def test_classes_and_structs(self): assert 'Namespace::Concrete::NestedClass' == type(n).__cpp_name__ def test_data_members(self): - import cppyy from cppyy.gbl import Concrete c = Concrete() @@ -219,7 +216,6 @@ def test_data_members(self): raises(TypeError, setattr, c, 'm_const_int', 71) def test_default_arguments(self): - import cppyy from cppyy.gbl import Concrete c = Concrete() @@ -231,7 +227,6 @@ def test_default_arguments(self): assert c.m_int == 27 def test_keyword_arguments(self): - import cppyy from cppyy.gbl import Concrete c = Concrete(n=17) @@ -251,19 +246,16 @@ def test_keyword_arguments(self): @mark.xfail def test_doc_strings(self): - import cppyy from cppyy.gbl import Concrete assert 'void Concrete::array_method(int* ad, int size)' in Concrete.array_method.__doc__ assert 'void Concrete::array_method(double* ad, int size)' in Concrete.array_method.__doc__ def test_enums(self): - import cppyy pass @mark.xfail(run=False, condition=IS_MAC, reason="Seg Fault") def test_functions(self): - import cppyy from cppyy.gbl import global_function, call_int_int_function, Namespace assert not(global_function == Namespace.global_function) @@ -282,24 +274,20 @@ def add(a, b): assert call_int_int_function(lambda x, y: x*y, 3, 7) == 21 def test_inheritance(self): - import cppyy pass def test_memory(self): - import cppyy from cppyy.gbl import Concrete c = Concrete() assert c.__python_owns__ == True def test_methods(self): - import cppyy pass def test_namespaces(self): - import cppyy pass @@ -310,28 +298,23 @@ def test_null(self): assert not cppyy.nullptr def test_operator_conversions(self): - import cppyy from cppyy.gbl import Concrete assert str(Concrete()) == 'Hello operator const char*!' def test_operator_overloads(self): - import cppyy pass def test_pointers(self): - import cppyy pass def test_pyobject(self): - import cppyy pass def test_ref(self): - import cppyy from cppyy.gbl import Concrete from ctypes import c_uint @@ -341,7 +324,6 @@ def test_ref(self): assert u.value == 42 def test_static_data_members(self): - import cppyy from cppyy.gbl import Concrete assert Concrete.s_int == 321 @@ -349,12 +331,10 @@ def test_static_data_members(self): assert Concrete.s_int == 123 def test_static_methods(self): - import cppyy pass def test_strings(self): - import cppyy pass @@ -366,23 +346,19 @@ def test_templated_classes(self): assert type(cppyy.gbl.std.vector(int)()) == cppyy.gbl.std.vector(int) def test_templated_functions(self): - import cppyy pass def test_templated_methods(self): - import cppyy pass def test_typedefs(self): - import cppyy from cppyy.gbl import Concrete, Concrete_t assert Concrete is Concrete_t def test_unary_operators(sef): - import cppyy pass @@ -479,7 +455,7 @@ def test_exceptions(self): caught = False try: cppyy.gbl.DocHelper.throw_an_error(0) - except exc_type as e: + except exc_type: caught = True assert caught == True assert caught == True @@ -738,7 +714,7 @@ def test10_stl_algorithm(self): @mark.skipif(IS_MAC and IS_CLING, reason="setup class fails with OS X cling") class TestADVERTISED: def setup_class(cls): - import cppyy + pass def test01_reduction_of_overloads(self): """Reduce available overloads to 1""" @@ -767,7 +743,8 @@ def pythonize_A(klass, name): def test02_use_c_void_p(self): """Use of opaque handles and ctypes.c_void_p""" - import cppyy, ctypes + import cppyy + import ctypes ### void pointer as opaque handle cppyy.cppdef("""namespace Advert02 { @@ -802,7 +779,8 @@ def test02_use_c_void_p(self): def test03_use_of_ctypes_and_enum(self): """Use of (opaque) enum through ctypes.c_void_p""" - import cppyy, ctypes + import cppyy + import ctypes cppyy.cppdef("""namespace Advert03 { enum SomeEnum1 { AA = -1, BB = 42 }; @@ -890,7 +868,8 @@ def test04_ptr_ptr_python_owns(self): def test05_ptr_ptr_with_array(self): """Example of ptr-ptr with array""" - import cppyy, ctypes + import cppyy + import ctypes cppyy.cppdef("""namespace Advert05 { struct SomeStruct { int i; }; @@ -916,7 +895,8 @@ def test05_ptr_ptr_with_array(self): def test06_c_char_p(self): """Example of ctypes.c_char_p usage""" - import cppyy, ctypes + import cppyy + import ctypes cppyy.cppdef("""namespace Advert06 { intptr_t createit(const char** out) { diff --git a/test/test_eigen.py b/test/test_eigen.py index bb4d3cb6..2974513e 100644 --- a/test/test_eigen.py +++ b/test/test_eigen.py @@ -1,6 +1,6 @@ -import py, os, sys -from pytest import mark, raises -from .support import setup_make, IS_CLANG_REPL, IS_CLING, IS_MAC_X86 +import os +from pytest import mark +from .support import IS_CLING, IS_MAC_X86 inc_paths = [os.path.join(os.path.sep, 'usr', 'include'), os.path.join(os.path.sep, 'usr', 'local', 'include')] @@ -15,7 +15,8 @@ @mark.skipif(eigen_path is None, reason="Eigen not found") class TestEIGEN: def setup_class(cls): - import cppyy, warnings + import cppyy + import warnings cppyy.add_include_path(eigen_path) with warnings.catch_warnings(): @@ -118,7 +119,7 @@ def test03_matrices_and_vectors(self): m = (m + MatrixXd.Constant(3, 3, 1.2)) * 50 v = VectorXd(3) - (v << 1).__comma__(2).__comma__(3); + (v << 1).__comma__(2).__comma__(3) assert (m*v).size() == v.size() @@ -151,7 +152,8 @@ def test04_resizing_through_assignment(self): @mark.skipif(eigen_path is None, reason="Eigen not found") class TestEIGEN_REGRESSIOn: def setup_class(cls): - import cppyy, warnings + import cppyy + import warnings cppyy.add_include_path(eigen_path) with warnings.catch_warnings(): @@ -162,7 +164,6 @@ def setup_class(cls): def test01_use_of_Map(self): """Use of Map (used to crash)""" - import cppyy from cppyy.gbl import Eigen assert Eigen.VectorXd diff --git a/test/test_fragile.py b/test/test_fragile.py index f795b63f..e9bd7f03 100644 --- a/test/test_fragile.py +++ b/test/test_fragile.py @@ -1,4 +1,6 @@ -import py, os, sys +import py +import os +import sys from pytest import raises, skip, mark from .support import setup_make, ispypy, IS_LINUX, IS_WINDOWS, IS_MAC_ARM, IS_CLANG_REPL, IS_MAC @@ -258,7 +260,7 @@ def test11_dir(self): S(int a, int c): _a{a}, _c{c} { } S(): _a{0}, _c{0} { } bool operator<(int i) { return i < (_a+_c); } - }; }"""); + }; }""") assert 'S' in dir(cppyy.gbl.GG) @@ -290,10 +292,9 @@ def test12_imports(self): # TODO: namespaces aren't loaded (and thus not added to sys.modules) # with just the from ... import statement; actual use is needed - from cppyy.gbl import fragile def fail_import(): - from cppyy.gbl import does_not_exist + pass raises(ImportError, fail_import) from cppyy.gbl.fragile import A, B, C, D @@ -413,16 +414,16 @@ def test16_opaque_handle(self): assert cppyy.addressof(handle) == 0x42 raises(TypeError, cppyy.gbl.fragile.OpaqueType) - assert not 'OpaqueType' in cppyy.gbl.fragile.__dict__ + assert 'OpaqueType' not in cppyy.gbl.fragile.__dict__ handle = cppyy.gbl.fragile.OpaqueHandle_t() assert not handle - addr = cppyy.gbl.fragile.create_handle(handle); + addr = cppyy.gbl.fragile.create_handle(handle) assert addr assert not not handle - assert cppyy.gbl.fragile.destroy_handle(handle, addr); + assert cppyy.gbl.fragile.destroy_handle(handle, addr) # now define OpaqueType cppyy.cppdef("namespace fragile { class OpaqueType { public: int m_int; }; }") @@ -436,7 +437,6 @@ def test16_opaque_handle(self): def test17_interactive(self): """Test the usage of 'from cppyy.interactive import *'""" - import sys if 0x030b0000 <= sys.hexversion: skip('"from cppyy.interactive import *" is no longer supported') @@ -444,7 +444,7 @@ def test17_interactive(self): oldsp = sys.path[:] sys.path.append('.') try: - import assert_interactive + pass finally: sys.path = oldsp @@ -471,9 +471,9 @@ def test19_gbl_contents(self): dd = dir(cppyy.gbl) - assert not 'TCanvasImp' in dd - assert not 'ESysConstants' in dd - assert not 'kDoRed' in dd + assert 'TCanvasImp' not in dd + assert 'ESysConstants' not in dd + assert 'kDoRed' not in dd @mark.xfail(condition=IS_MAC, reason="Fails on OS X") def test20_capture_output(self): @@ -506,7 +506,8 @@ def test20_capture_output(self): def test21_failing_cppcode(self): """Check error behavior of failing C++ code""" - import cppyy, string, re + import cppyy + import re allspace = re.compile(r'\s+') def get_errmsg(exc, allspace=allspace): @@ -544,7 +545,7 @@ def test22_cppexec(self): assert cppyy.gbl.interactive_b == 4 with raises(SyntaxError): - cppyy.cppexec("doesnotexist"); + cppyy.cppexec("doesnotexist") def test23_set_debug(self): """Setting of debugging facilities""" @@ -565,9 +566,8 @@ def test24_asan(self): """Check availability of ASAN with gcc""" import cppyy - import sys - if not 'linux' in sys.platform: + if 'linux' not in sys.platform: return cppyy.include('sanitizer/asan_interface.h') @@ -576,7 +576,8 @@ def test24_asan(self): def test25_cppdef_error_reporting(self): """Check error reporting of cppyy.cppdef""" - import cppyy, warnings + import cppyy + import warnings assert cppyy.gbl.fragile.add42(1) == 43 # brings in symbol from library @@ -636,7 +637,6 @@ def test01_abortive_signals(self): assert issubclass(cppyy.ll.IllegalInstruction, cppyy.ll.FatalError) assert issubclass(cppyy.ll.AbortSignal, cppyy.ll.FatalError) - import os os.putenv('CPPYY_CRASH_QUIET', '1') with raises((cppyy.ll.SegmentationViolation, cppyy.ll.IllegalInstruction)): diff --git a/test/test_leakcheck.py b/test/test_leakcheck.py index 837e3d73..6cd39813 100644 --- a/test/test_leakcheck.py +++ b/test/test_leakcheck.py @@ -1,6 +1,8 @@ -import py, os, sys +import py +import os +import sys from pytest import mark, skip -from .support import setup_make, pylong, pyunicode, IS_CLANG_REPL +from .support import setup_make currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("datatypesDict")) @@ -17,7 +19,8 @@ def setup_module(mod): @mark.skipif(nopsutil == True, reason="module psutil not installed") class TestLEAKCHECK: def setup_class(cls): - import cppyy, psutil + import cppyy + import psutil cls.test_dct = test_dct cls.memory = cppyy.load_reflection_info(cls.test_dct) diff --git a/test/test_lowlevel.py b/test/test_lowlevel.py index 18443b0b..606034aa 100644 --- a/test/test_lowlevel.py +++ b/test/test_lowlevel.py @@ -1,6 +1,7 @@ -import py, os, sys +import py +import sys from pytest import raises, skip, mark -from .support import setup_make, pylong, pyunicode, IS_WINDOWS, ispypy, IS_CLANG_REPL, IS_MAC +from .support import setup_make, IS_WINDOWS, ispypy, IS_MAC currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("datatypesDict")) @@ -51,7 +52,6 @@ def test03_memory(self): """Memory allocation and free-ing""" import cppyy - from cppyy import ll # regular C malloc/free mem = cppyy.gbl.malloc(16) @@ -87,7 +87,8 @@ def test03_memory(self): def test04_python_casts(self): """Casts to common Python pointer encapsulations""" - import cppyy, cppyy.ll + import cppyy + import cppyy.ll cppyy.cppdef("""namespace pycasts { struct SomeObject{}; @@ -109,7 +110,7 @@ def test04_python_casts(self): def test05_array_as_ref(self): """Use arrays for pass-by-ref""" - import cppyy, sys + import cppyy from array import array ctd = cppyy.gbl.CppyyTestData() @@ -164,7 +165,8 @@ def test06_ctypes_as_ref_and_ptr(self): # c_double double float # c_longdouble long double float - import cppyy, ctypes + import cppyy + import ctypes ctd = cppyy.gbl.CppyyTestData() @@ -227,7 +229,7 @@ def test06_ctypes_as_ref_and_ptr(self): import cppyy.ll # boolean type - b = POINTER(ctypes.c_bool)(); ctd.set_bool_ppa(b); + b = POINTER(ctypes.c_bool)(); ctd.set_bool_ppa(b) assert b[0] == True; assert b[1] == False; assert b[2] == True cppyy.ll.array_delete(b) @@ -288,7 +290,8 @@ def test07_ctypes_pointer_types(self): # c_wchar_p wchar_t* (NULL terminated) unicode or None # c_void_p void* int/long or None - import cppyy, ctypes + import cppyy + import ctypes ctd = cppyy.gbl.CppyyTestData() @@ -309,7 +312,8 @@ def test07_ctypes_pointer_types(self): def test08_ctypes_type_correctness(self): """If types don't match with ctypes, expect exceptions""" - import cppyy, ctypes + import cppyy + import ctypes ctd = cppyy.gbl.CppyyTestData() @@ -317,7 +321,7 @@ def test08_ctypes_type_correctness(self): if not IS_WINDOWS: meth_types.append('long') - i = ctypes.c_int(0); + i = ctypes.c_int(0) for ext in ['_r', '_p']: for meth in meth_types: with raises(TypeError): getattr(ctd, 'set_'+meth+ext)(i) @@ -340,7 +344,8 @@ def test09_numpy_bool_array(self): def test10_array_of_const_char_star(self): """Test passting of const char*[]""" - import cppyy, ctypes + import cppyy + import ctypes def py2c(pyargs): cargsn = (ctypes.c_char_p * len(pyargs))(*pyargs) @@ -371,7 +376,8 @@ def py2c(pyargs): def test11_array_of_const_char_ref(self): """Test passting of const char**&""" - import cppyy, ctypes + import cppyy + import ctypes import cppyy.ll # IN parameter case diff --git a/test/test_numba.py b/test/test_numba.py index 5077fdc4..ef608029 100644 --- a/test/test_numba.py +++ b/test/test_numba.py @@ -1,7 +1,6 @@ -import py, os, sys -import math, time +import math +import time from pytest import mark, raises -from .support import setup_make try: import numba @@ -12,8 +11,7 @@ class TestREFLEX: def setup_class(cls): - import cppyy - import cppyy.reflex + pass def test01_instance_box_unbox(self): """Access to box/unbox methods""" @@ -79,8 +77,7 @@ class MyData_d1 { @mark.skipif(has_numba == False, reason="numba not found") class TestNUMBA: def setup_class(cls): - import cppyy - import cppyy.numba_ext + pass def compare(self, go_slow, go_fast, N, *args): t0 = time.time() @@ -293,8 +290,7 @@ def go_fast(a): @mark.skipif(has_numba == False, reason="numba not found") class TestNUMBA_DOC: def setup_class(cls): - import cppyy - import cppyy.numba_ext + pass @mark.xfail def test01_templated_freefunction(self): diff --git a/test/test_operators.py b/test/test_operators.py index 9ddd488b..fb8b557b 100644 --- a/test/test_operators.py +++ b/test/test_operators.py @@ -1,6 +1,6 @@ -import py, os, sys +import py from pytest import raises, skip, mark -from .support import setup_make, pylong, maxvalue, IS_WINDOWS, IS_MAC, IS_CLANG_REPL, IS_CLING +from .support import setup_make, pylong, maxvalue, IS_WINDOWS, IS_MAC, IS_CLING currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("operatorsDict")) @@ -56,7 +56,7 @@ def test02_unary_math_operators(self): n /= number(2) assert n == number(100) - nn = -n; + nn = -n assert nn == number(-100) def test03_comparison_operators(self): @@ -116,7 +116,7 @@ def test05_exact_types(self): def test06_approximate_types(self): """Test converter operators of approximate types""" - import cppyy, sys + import cppyy gbl = cppyy.gbl @@ -128,7 +128,7 @@ def test06_approximate_types(self): assert o.m_uint == 2147483647 + 32 assert pylong(o) == 2147483647 + 32 - o = gbl.operator_unsigned_long(); + o = gbl.operator_unsigned_long() o.m_ulong = maxvalue + 128 assert o.m_ulong == maxvalue + 128 assert pylong(o) == maxvalue + 128 diff --git a/test/test_overloads.py b/test/test_overloads.py index 67b85ac0..c1768393 100644 --- a/test/test_overloads.py +++ b/test/test_overloads.py @@ -1,4 +1,4 @@ -import py, os, sys +import py from pytest import raises, skip, mark from .support import setup_make, ispypy, IS_WINDOWS, IS_MAC, IS_MAC_ARM @@ -135,7 +135,8 @@ def test06_double_int_overloads(self): def test07_mean_overloads(self): """Adapted test for array overloading""" - import cppyy, array + import cppyy + import array cmean = cppyy.gbl.calc_mean numbers = [8, 2, 4, 2, 4, 2, 4, 4, 1, 5, 6, 3, 7] @@ -173,7 +174,7 @@ def test09_bool_int_overloads(self): cpp = cppyy.gbl - cppyy.cppdef("namespace BoolInt1 { int fff(int i) { return i; } }"); + cppyy.cppdef("namespace BoolInt1 { int fff(int i) { return i; } }") cppyy.cppdef("namespace BoolInt1 { bool fff(bool i) { return i; } }") assert type(cpp.BoolInt1.fff(0)) == int @@ -183,7 +184,7 @@ def test09_bool_int_overloads(self): assert type(cpp.BoolInt1.fff(True)) == bool assert type(cpp.BoolInt1.fff(False)) == bool - cppyy.cppdef("namespace BoolInt2 { int fff(int i) { return i; } }"); + cppyy.cppdef("namespace BoolInt2 { int fff(int i) { return i; } }") cppyy.cppdef("namespace BoolInt2 { bool fff(bool i) { return i; } }") assert type(cpp.BoolInt2.fff(True)) == bool @@ -193,7 +194,7 @@ def test09_bool_int_overloads(self): assert type(cpp.BoolInt2.fff(1)) == int assert type(cpp.BoolInt2.fff(2)) == int - cppyy.cppdef("namespace BoolInt3 { int fff(int i) { return i; } }"); + cppyy.cppdef("namespace BoolInt3 { int fff(int i) { return i; } }") assert type(cpp.BoolInt3.fff(True)) == int assert type(cpp.BoolInt3.fff(False)) == int diff --git a/test/test_pythonify.py b/test/test_pythonify.py index 725c43e4..a1896c68 100644 --- a/test/test_pythonify.py +++ b/test/test_pythonify.py @@ -1,6 +1,6 @@ -import py, os, sys +import py from pytest import raises, skip, mark -from .support import setup_make, pylong, ispypy, IS_CLANG_REPL, IS_CLING, IS_MAC_ARM, IS_MAC_X86, IS_MAC +from .support import setup_make, pylong, ispypy, IS_CLING, IS_MAC currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("example01Dict")) @@ -36,7 +36,7 @@ def test02_finding_classes(self): def test03_calling_static_functions(self): """Test calling of static methods""" - import cppyy, sys, math + import cppyy example01_class = cppyy.gbl.example01 res = example01_class.staticAddOneToInt(1) assert res == 2 @@ -203,7 +203,8 @@ def test08_global_functions(self): def test09_memory(self): """Test proper C++ destruction by the garbage collector""" - import cppyy, gc + import cppyy + import gc example01_class = cppyy.gbl.example01 payload_class = cppyy.gbl.payload @@ -341,7 +342,8 @@ def test15_installable_function(self): def test16_subclassing(self): """A sub-class on the python side should have that class as type""" - import cppyy, gc + import cppyy + import gc gc.collect() example01 = cppyy.gbl.example01 @@ -518,7 +520,7 @@ class MyClass {}; } }""") def pyfoo(a=10, b=20, c=5, d=4): - return a-b//c*d; + return a-b//c*d ns = cppyy.gbl.KeyWordsAndDefaults diff --git a/test/test_pythonization.py b/test/test_pythonization.py index dc3e5f0b..4fe572df 100644 --- a/test/test_pythonization.py +++ b/test/test_pythonization.py @@ -1,6 +1,7 @@ -import py, os, sys +import py +import sys from pytest import raises, mark -from .support import setup_make, pylong, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_CLANG_REPL, IS_CLING +from .support import setup_make, IS_MAC, IS_CLING currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("pythonizablesDict")) @@ -201,7 +202,8 @@ def test06_executors(self): def test07_creates_flag(self): """Effect of creates flag on return type""" - import cppyy, gc + import cppyy + import gc pz = cppyy.gbl.pyzables Countable = pz.Countable diff --git a/test/test_regression.py b/test/test_regression.py index a58b3791..217445d7 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -1,13 +1,13 @@ -import py, os, sys +import os +import sys from pytest import raises, skip, mark -from .support import setup_make, IS_WINDOWS, ispypy, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC +from .support import IS_WINDOWS, ispypy, IS_CLANG_REPL, IS_CLING, IS_MAC_ARM, IS_MAC class TestREGRESSION: helpout = [] def setup_class(cls): - import cppyy def stringpager(text, cls=cls): cls.helpout.append(text) @@ -19,7 +19,8 @@ def stringpager(text, cls=cls): def test01_kdcraw(self): """Doc strings for KDcrawIface (used to crash).""" - import cppyy, pydoc + import cppyy + import pydoc # TODO: run a find for these paths qtpath = "/usr/include/qt5" @@ -52,9 +53,10 @@ def test02_dir(self): if ispypy: skip('hangs (??) in pypy') - import cppyy, pydoc + import cppyy + import pydoc - assert not '__abstractmethods__' in dir(cppyy.gbl.cling.runtime.gCling) + assert '__abstractmethods__' not in dir(cppyy.gbl.cling.runtime.gCling) assert '__class__' in dir(cppyy.gbl.cling.runtime.gCling) self.__class__.helpout = [] @@ -66,12 +68,12 @@ def test02_dir(self): cppyy.cppdef("namespace cppyy_regression_test { void iii() {}; }") - assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__ - assert not '__abstractmethods__' in dir(cppyy.gbl.cppyy_regression_test) + assert 'iii' not in cppyy.gbl.cppyy_regression_test.__dict__ + assert '__abstractmethods__' not in dir(cppyy.gbl.cppyy_regression_test) assert '__class__' in dir(cppyy.gbl.cppyy_regression_test) assert 'iii' in dir(cppyy.gbl.cppyy_regression_test) - assert not 'iii' in cppyy.gbl.cppyy_regression_test.__dict__ + assert 'iii' not in cppyy.gbl.cppyy_regression_test.__dict__ assert cppyy.gbl.cppyy_regression_test.iii assert 'iii' in cppyy.gbl.cppyy_regression_test.__dict__ @@ -84,7 +86,8 @@ def test02_dir(self): def test03_pyfunc_doc(self): """Help on a generated pyfunc used to crash.""" - import cppyy, pydoc, sys + import cppyy + import pydoc import sysconfig as sc cppyy.add_include_path(sc.get_config_var("INCLUDEPY")) @@ -104,7 +107,8 @@ def test03_pyfunc_doc(self): def test04_avx(self): """Test usability of AVX by default.""" - import cppyy, subprocess + import cppyy + import subprocess has_avx = False try: @@ -143,7 +147,7 @@ class AllDefault { };""") a = cppyy.gbl.AllDefault[int](24) - a.m_t = 21; + a.m_t = 21 assert a.do_stuff() == 24 def test06_default_float_or_unsigned_argument(self): @@ -174,7 +178,8 @@ def test06_default_float_or_unsigned_argument(self): def test07_class_refcounting(self): """The memory regulator would leave an additional refcount on classes""" - import cppyy, gc, sys + import cppyy + import gc x = cppyy.gbl.std.vector['float'] old_refcnt = sys.getrefcount(x) @@ -202,7 +207,7 @@ def test08_typedef_identity(self): assert PyABC.S2.S1_coll assert 'S1_coll' in dir(PyABC.S2) - assert not 'vector' in dir(PyABC.S2) + assert 'vector' not in dir(PyABC.S2) assert PyABC.S2.S1_coll is cppyy.gbl.std.vector('const PyABC::S1*') @mark.xfail(condition=(IS_MAC and IS_CLING), reason="fails on OSX-Cling") @@ -496,7 +501,6 @@ def test19_std_string_hash(self): import cppyy - import cppyy s = cppyy.gbl.std.string("text") d = {} @@ -590,7 +594,8 @@ class Bar { def test23_copy_constructor(self): """Copy construct an object into an empty (NULL) proxy""" - import cppyy, gc + import cppyy + import gc cppyy.cppdef("""\ namespace regression_test22 { @@ -743,7 +748,8 @@ def test26_const_charptr_data(self): def test27_exception_by_value(self): """Proper memory management of exception return by value""" - import cppyy, gc + import cppyy + import gc cppyy.cppdef("""\ namespace ExceptionByValue { @@ -1040,7 +1046,8 @@ def test35_filesytem(self): def test36_ctypes_sizeof(self): """cppyy.sizeof forwards to ctypes.sizeof where necessary""" - import cppyy, ctypes + import cppyy + import ctypes cppyy.cppdef("""\ namespace test36_ctypes_sizeof { @@ -1161,7 +1168,7 @@ def test39_vector_of_pointers_conversion(self): }; }""") cppyy.gbl.VectorOfPointers - from cppyy.gbl.VectorOfPointers import Base1, Derived1, Owner + from cppyy.gbl.VectorOfPointers import Base1, Owner o = Owner() @@ -1198,8 +1205,7 @@ def test39_vector_of_pointers_conversion(self): std::vector vec3 { &d3 }; }""") - from cppyy.gbl import std - from cppyy.gbl.VectorOfPointers import Base2, Derived2, Base3, Derived3, vec2, vec3 + from cppyy.gbl.VectorOfPointers import Base2, Derived2, Derived3, vec2, vec3 assert len(vec2) == 1 assert type(vec2[0]) == Base2 diff --git a/test/test_stltypes.py b/test/test_stltypes.py index 8bad09be..8328b26e 100644 --- a/test/test_stltypes.py +++ b/test/test_stltypes.py @@ -1,7 +1,8 @@ # -*- coding: UTF-8 -*- -import py, os, sys +import py +import sys from pytest import raises, skip, mark -from .support import setup_make, pylong, pyunicode, maxvalue, ispypy, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC +from .support import setup_make, pylong, pyunicode, maxvalue, ispypy, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("stltypesDict")) @@ -416,7 +417,7 @@ def test08_vector_enum(self): assert cppyy.gbl.VecTestEnum for tp in ['VecTestEnum', cppyy.gbl.VecTestEnum]: ve = cppyy.gbl.std.vector[tp]() - ve.push_back(cppyy.gbl.EVal1); + ve.push_back(cppyy.gbl.EVal1) assert ve[0] == 1 ve[0] = cppyy.gbl.EVal2 assert ve[0] == 3 @@ -424,7 +425,7 @@ def test08_vector_enum(self): assert cppyy.gbl.VecTestEnumNS.VecTestEnum for tp in ['VecTestEnumNS::VecTestEnum', cppyy.gbl.VecTestEnumNS.VecTestEnum]: ve = cppyy.gbl.std.vector['VecTestEnumNS::VecTestEnum']() - ve.push_back(cppyy.gbl.VecTestEnumNS.EVal1); + ve.push_back(cppyy.gbl.VecTestEnumNS.EVal1) assert ve[0] == 5 ve[0] = cppyy.gbl.VecTestEnumNS.EVal2 assert ve[0] == 42 @@ -446,7 +447,6 @@ def test09_vector_of_string(self): def test10_vector_std_distance(self): """Use of std::distance with vector""" - import cppyy from cppyy.gbl import std v = std.vector[int]([1, 2, 3]) @@ -1081,7 +1081,6 @@ def test01_builtin_list_type(self): def test02_empty_list_type(self): """Test behavior of empty list""" - import cppyy from cppyy.gbl import std a = std.list(int)() @@ -1234,7 +1233,8 @@ def test03_empty_maptype(self): def test04_unsignedvalue_typemap_types(self): """Test assignability of maps with unsigned value types""" - import cppyy, math, sys + import cppyy + import math std = cppyy.gbl.std for mtype in (std.map, std.unordered_map): @@ -1350,7 +1350,6 @@ def setup_class(cls): def test01_builtin_vector_iterators(self): """Test iterator comparison with operator== reflected""" - import cppyy from cppyy.gbl import std v = std.vector(int)() @@ -1513,7 +1512,6 @@ def setup_class(cls): def test01_array_of_basic_types(self): """Usage of std::array of basic types""" - import cppyy from cppyy.gbl import std a = std.array[int, 4]() @@ -1526,7 +1524,6 @@ def test01_array_of_basic_types(self): def test02_array_of_pods(self): """Usage of std::array of PODs""" - import cppyy from cppyy import gbl from cppyy.gbl import std @@ -1550,7 +1547,6 @@ def test02_array_of_pods(self): def test03_array_of_pointer_to_pods(self): """Usage of std::array of pointer to PODs""" - import cppyy from cppyy import gbl from cppyy.gbl import std @@ -1624,7 +1620,8 @@ def test01_string_through_string_view(self): def test02_string_view_from_unicode(self): """Life-time management of converted unicode strings""" - import cppyy, gc + import cppyy + import gc # view on (converted) unicode text = cppyy.gbl.std.string_view('''\ @@ -1778,12 +1775,12 @@ def test05_contains(self): S = cppyy.gbl.std.set[int](range(2**20)) assert 1337 in S - assert not (2**30 in S) + assert 2**30 not in S # not a true test, but this'll take a noticable amount of time (>1min) if # there is a regression somehow for i in range(100): - assert not (2**30 in S) + assert 2**30 not in S class TestSTLTUPLE: @@ -1842,7 +1839,7 @@ def test02_tuple_size(self): def test03_tuple_iter(self): """Pack/unpack tuples""" - import cppyy, ctypes + import cppyy std = cppyy.gbl.std t = std.make_tuple(1, '2', 5.) @@ -1857,7 +1854,8 @@ def test03_tuple_iter(self): def test04_tuple_lifeline(self): """Tuple memory management""" - import cppyy, gc + import cppyy + import gc std = cppyy.gbl.std cppyy.cppdef("""\ @@ -1989,7 +1987,8 @@ def raiseit(cls): def test03_memory(self): """Memory handling of C++ c// helper for exception base class testing""" - import cppyy, gc + import cppyy + import gc MyError = cppyy.gbl.MyError YourError = cppyy.gbl.YourError @@ -2037,7 +2036,8 @@ def test04_from_cpp(self): if ispypy: skip('currently terminates') - import cppyy, gc + import cppyy + import gc gc.collect() assert cppyy.gbl.GetMyErrorCount() == 0 diff --git a/test/test_streams.py b/test/test_streams.py index 9a2dc5ac..20317dbf 100644 --- a/test/test_streams.py +++ b/test/test_streams.py @@ -1,6 +1,6 @@ -import py, os, sys -from pytest import raises, mark -from .support import setup_make, IS_MAC, IS_CLANG_REPL +import py +from pytest import mark +from .support import setup_make, IS_MAC currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("std_streamsDict")) @@ -30,7 +30,7 @@ def test02_std_cout(self): import cppyy - assert not (cppyy.gbl.std.cout is None) + assert cppyy.gbl.std.cout is not None @mark.xfail(condition=IS_MAC, reason="Fails on OS X") def test03_consistent_naming_if_char_traits(self): @@ -44,7 +44,7 @@ def test03_consistent_naming_if_char_traits(self): o << "TEST STRING"; } }""") - s = cppyy.gbl.std.ostringstream(); + s = cppyy.gbl.std.ostringstream() # base class used to fail to match cppyy.gbl.stringstream_base.pass_through_base(s) assert s.str() == "TEST STRING" diff --git a/test/test_templates.py b/test/test_templates.py index 0a418e27..7e19d792 100644 --- a/test/test_templates.py +++ b/test/test_templates.py @@ -1,6 +1,6 @@ -import py, os +import py from pytest import raises, mark -from .support import setup_make, pylong, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_LINUX +from .support import setup_make, pylong, IS_CLANG_REPL, IS_CLING, IS_MAC currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("templatesDict")) @@ -806,7 +806,8 @@ def test28_enum_in_constructor(self): def test29_function_ptr_as_template_arg(self): """Function pointers as template arguments""" - import cppyy, sys + import cppyy + import sys # different templates used to prevent memoization caches resolving calls cppyy.cppdef("""\