Fix operation under Python 3.4

Fri, 24 May 2019 15:32:10 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 24 May 2019 15:32:10 +0300
changeset 37
e46fa477007b
parent 36
2753aad79678
child 38
66c9591b733d

Fix operation under Python 3.4

tests/subfiles.py file | annotate | diff | comparison | revisions
testsuite.py file | annotate | diff | comparison | revisions
--- a/tests/subfiles.py	Fri May 24 14:20:18 2019 +0200
+++ b/tests/subfiles.py	Fri May 24 15:32:10 2019 +0300
@@ -6,7 +6,7 @@
 ini_path = Path(dirname(__file__)) / 'library-standards.ini'
 library_standards = ConfigParser()
 
-with open(ini_path) as file:
+with ini_path.open() as file:
     library_standards.read_file(file)
 
 def determinant_test(model):
--- a/testsuite.py	Fri May 24 14:20:18 2019 +0200
+++ b/testsuite.py	Fri May 24 15:32:10 2019 +0300
@@ -17,6 +17,12 @@
 def notice(bad_object, error_name, **args):
     return report_element(bad_object, 'notice', error_name, args)
 
+def name_of_package(package):
+    if isinstance(package, tuple):
+        return package[1]
+    else:
+        return package.name
+
 def test_discovery():
     '''
         Finds all test modules and yields their names.
@@ -24,7 +30,7 @@
     from pkgutil import walk_packages
     import tests
     yield from sorted(
-        'tests.' + result.name
+        'tests.' + name_of_package(result)
         for result in walk_packages(tests.__path__)
     )
 

mercurial