[jhbuild/ci-tests: 4/5] tests: Make the tests pytest compatible



commit 50b89fce1ed8ec24677088831c178779998622b1
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Sep 21 14:55:29 2019 +0200

    tests: Make the tests pytest compatible
    
    Rename the file so pytests finds it by default.
    Rename a class to avoid a pytest warning.
    Handle pytest monkeypatching stdin.

 jhbuild/utils/cmds.py            | 2 +-
 tests/{tests.py => test_main.py} | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/jhbuild/utils/cmds.py b/jhbuild/utils/cmds.py
index 131b24b9..66676915 100644
--- a/jhbuild/utils/cmds.py
+++ b/jhbuild/utils/cmds.py
@@ -173,7 +173,7 @@ def pprint_output(pipe, format_line):
         read_set.append(pipe.stdout)
     if pipe.stderr:
         read_set.append(pipe.stderr)
-    if not sys.stdin.closed:
+    if not getattr(sys.stdin, "closed", True):
         read_set.append(sys.stdin)
 
     out_data = err_data = ''
diff --git a/tests/tests.py b/tests/test_main.py
similarity index 99%
rename from tests/tests.py
rename to tests/test_main.py
index 8f4865f4..bd3cf636 100644
--- a/tests/tests.py
+++ b/tests/test_main.py
@@ -84,7 +84,7 @@ if sys.platform.startswith('win'):
             cmd_list = subprocess_win32.cmdline2list (cmdline)
             self.assertEqual (cmd_list, ['test', 'no quotes', '!=', '"no\\ quotes"'])
 
-class TestConfig(jhbuild.config.Config):
+class _TestConfig(jhbuild.config.Config):
 
     # The Config base class calls setup_env() in the constructor, but
     # we need to override some attributes before calling it.
@@ -115,7 +115,7 @@ class JhbuildConfigTestCase(unittest.TestCase):
 
     def make_config(self):
         temp_dir = self.make_temp_dir()
-        config = TestConfig(None, [])
+        config = _TestConfig(None, [])
         config.checkoutroot = os.path.abspath(os.path.join(temp_dir, 'checkout'))
         config.prefix = os.path.abspath(os.path.join(temp_dir, 'prefix'))
         config.top_builddir = os.path.join(config.prefix, '_jhbuild')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]