ya2 · news · projects · code · about

minor refactoring
authorFlavio Calva <f.calva@gmail.com>
Tue, 5 Jul 2022 17:58:10 +0000 (18:58 +0100)
committerFlavio Calva <f.calva@gmail.com>
Tue, 5 Jul 2022 17:58:10 +0000 (18:58 +0100)
prj.org
tests/ya2/build/test_build.py

diff --git a/prj.org b/prj.org
index 65182035b3bbd436227d4da790766e5711ef5bc8..2a3089b837abd0c7cfbfb0d9b61aa93ef22b4969 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -13,7 +13,7 @@
 - [ ] current nodepaths (render3d)
 - [ ] current accepting events
 - [ ] current buffers
-* READY refactoring
+* READY refactoring (recurring task)
 * BACKLOG intro animation (from target item to start position)
 * BACKLOG buttons of the scenes enabled sequentially
 - [ ] each scene has a version
index 6713addb2fdc745f99605cdcb58bddac13c127fc..5546cf1cafb28abd37fa2f8c75ef8ca1bd36d656 100644 (file)
@@ -1,13 +1,14 @@
 '''Unit tests for lib.build.'''
 from pathlib import Path
 import sys
-if '' in sys.path: sys.path.remove('')
+if '' in sys.path:
+    sys.path.remove('')
 sys.path.append(str(Path(__file__).parent.parent.parent.parent))
 from os import getcwd, makedirs, walk
 from os.path import basename
 from shutil import rmtree
 from unittest import TestCase
-from re import compile
+import re
 from ya2.build.build import InsideDir, files, exec_cmd, _branch, _version, \
     to_be_built
 
@@ -18,13 +19,16 @@ class BuildTests(TestCase):
         makedirs('test_get_files/a')
         makedirs('test_get_files/b')
         makedirs('test_get_files/c')
-        with open('test_get_files/a/c.ext1', 'w') as ftest:
+        with open('test_get_files/a/c.ext1', 'w', encoding='utf8') as ftest:
             ftest.write('0123456789')
-        with open('test_get_files/a/d.ext2', 'w'): pass
-        with open('test_get_files/b/e.ext2', 'w') as ftest:
+        with open('test_get_files/a/d.ext2', 'w', encoding='utf8'):
+            pass
+        with open('test_get_files/b/e.ext2', 'w', encoding='utf8') as ftest:
             ftest.write('0123456789')
-        with open('test_get_files/b/f.ext3', 'w'): pass
-        with open('test_get_files/c/g.ext2', 'w'): pass
+        with open('test_get_files/b/f.ext3', 'w', encoding='utf8'):
+            pass
+        with open('test_get_files/c/g.ext2', 'w', encoding='utf8'):
+            pass
 
     def tearDown(self):
         rmtree('test_get_files')
@@ -39,8 +43,8 @@ class BuildTests(TestCase):
         patterns = [
             "^0a[0-9]+$",
             "^0rc[0-9]+$",
-            "^0\.[0-9]+$"]
-        compiled = [compile(pattern) for pattern in patterns]
+            r"^0\.[0-9]+$"]
+        compiled = [re.compile(pattern) for pattern in patterns]
         matches = [pattern.match(_version()) for pattern in compiled]
         self.assertTrue(any(matches))
 
@@ -61,8 +65,8 @@ class BuildTests(TestCase):
 
     def test_to_be_built(self):
         tgt = 'test_get_files/tgt.txt'
-        with open('test_get_files/src.txt', 'w') as fsrc:
+        with open('test_get_files/src.txt', 'w', encoding='utf8') as fsrc:
             fsrc.write('src')
-        with open(tgt, 'w') as ftgt:
+        with open(tgt, 'w', encoding='utf8') as ftgt:
             ftgt.write('tgt')
         self.assertTrue(to_be_built(tgt, ['test_get_files/src.txt']))