Hello community,

here is the log from the commit of package python-pytest-console-scripts for 
openSUSE:Factory checked in at 2019-11-15 22:38:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-console-scripts (Old)
 and      /work/SRC/openSUSE:Factory/.python-pytest-console-scripts.new.26869 
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pytest-console-scripts"

Fri Nov 15 22:38:29 2019 rev:4 rq:748852 version:0.2.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-pytest-console-scripts/python-pytest-console-scripts.changes
      2019-09-26 20:40:43.086625203 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-pytest-console-scripts.new.26869/python-pytest-console-scripts.changes
   2019-11-15 22:38:43.392217073 +0100
@@ -1,0 +2,6 @@
+Fri Nov 15 10:41:07 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 0.2.0:
+  * no upstream changelog
+
+-------------------------------------------------------------------

Old:
----
  pytest-console-scripts-0.1.10.tar.gz

New:
----
  pytest-console-scripts-0.2.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pytest-console-scripts.spec ++++++
--- /var/tmp/diff_new_pack.9MY2Qf/_old  2019-11-15 22:38:44.028219135 +0100
+++ /var/tmp/diff_new_pack.9MY2Qf/_new  2019-11-15 22:38:44.052219212 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-pytest-console-scripts
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LLC.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-pytest-console-scripts
-Version:        0.1.10
+Version:        0.2.0
 Release:        0
 Summary:        Pytest plugin for testing console scripts
 License:        MIT
@@ -61,7 +61,7 @@
 %python_expand %fdupes %{buildroot}%{$python_sitelib}
 
 %check
-%python_exec setup.py test
+%pytest
 
 %files %{python_files}
 %license LICENSE

++++++ pytest-console-scripts-0.1.10.tar.gz -> 
pytest-console-scripts-0.2.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-console-scripts-0.1.10/PKG-INFO 
new/pytest-console-scripts-0.2.0/PKG-INFO
--- old/pytest-console-scripts-0.1.10/PKG-INFO  2019-09-10 15:30:26.000000000 
+0200
+++ new/pytest-console-scripts-0.2.0/PKG-INFO   2019-11-08 19:36:16.000000000 
+0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: pytest-console-scripts
-Version: 0.1.10
+Version: 0.2.0
 Summary: Pytest plugin for testing console scripts
 Home-page: https://github.com/kvas-it/pytest-console-scripts
 Author: Vasily Kuznetsov
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pytest-console-scripts-0.1.10/pytest_console_scripts.egg-info/PKG-INFO 
new/pytest-console-scripts-0.2.0/pytest_console_scripts.egg-info/PKG-INFO
--- old/pytest-console-scripts-0.1.10/pytest_console_scripts.egg-info/PKG-INFO  
2019-09-10 15:30:26.000000000 +0200
+++ new/pytest-console-scripts-0.2.0/pytest_console_scripts.egg-info/PKG-INFO   
2019-11-08 19:36:16.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: pytest-console-scripts
-Version: 0.1.10
+Version: 0.2.0
 Summary: Pytest plugin for testing console scripts
 Home-page: https://github.com/kvas-it/pytest-console-scripts
 Author: Vasily Kuznetsov
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pytest-console-scripts-0.1.10/pytest_console_scripts.py 
new/pytest-console-scripts-0.2.0/pytest_console_scripts.py
--- old/pytest-console-scripts-0.1.10/pytest_console_scripts.py 2019-09-10 
15:17:36.000000000 +0200
+++ new/pytest-console-scripts-0.2.0/pytest_console_scripts.py  2019-11-08 
19:27:00.000000000 +0100
@@ -2,6 +2,7 @@
 
 import distutils.spawn
 import io
+import logging
 import os
 import subprocess
 import sys
@@ -37,6 +38,14 @@
     )
 
 
+def pytest_configure(config):
+    config.addinivalue_line(
+        'markers',
+        'script_launch_mode: how to run python scripts under test '
+            '(inprocess|subprocess|both)',
+    )
+
+
 def _get_mark_mode(metafunc):
     """Return launch mode as indicated by test function marker or None."""
     marker = metafunc.definition.get_closest_marker('script_launch_mode')
@@ -108,6 +117,33 @@
             return self.run_inprocess(command, *arguments, **options)
         return self.run_subprocess(command, *arguments, **options)
 
+    def _save_and_reset_logger(self):
+        """Do a very basic reset of the root logger and return its config.
+
+        This allows scripts to call logging.basicConfig(...) and have
+        it work as expected. It might not work for more sophisticated logging
+        setups but it's simple and covers the basic usage whereas implementing
+        a comprehensive fix is impossible in a compatible way.
+
+        """
+        logger = logging.getLogger()
+        config = {
+            'level': logger.level,
+            'handlers': logger.handlers,
+            'disabled': logger.disabled,
+        }
+        logger.handlers = []
+        logger.disabled = False
+        logger.setLevel(logging.NOTSET)
+        return config
+
+    def _restore_logger(self, config):
+        """Restore logger to previous configuration."""
+        logger = logging.getLogger()
+        logger.handlers = config['handlers']
+        logger.disabled = config['disabled']
+        logger.setLevel(config['level'])
+
     def run_inprocess(self, command, *arguments, **options):
         cmdargs = [command] + list(arguments)
         script = py.path.local(distutils.spawn.find_executable(command))
@@ -120,6 +156,7 @@
         stderr_patch = mock.patch('sys.stderr', new=stderr)
         argv_patch = mock.patch('sys.argv', new=cmdargs)
         saved_dir = os.getcwd()
+        logger_conf = self._save_and_reset_logger()
 
         if 'env' in options:
             old_env = os.environ
@@ -146,6 +183,8 @@
                     traceback.print_exception(et, ev, tb.tb_next)
                 finally:
                     del tb
+
+        self._restore_logger(logger_conf)
         os.chdir(saved_dir)
 
         if 'env' in options:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-console-scripts-0.1.10/setup.py 
new/pytest-console-scripts-0.2.0/setup.py
--- old/pytest-console-scripts-0.1.10/setup.py  2019-09-10 15:22:01.000000000 
+0200
+++ new/pytest-console-scripts-0.2.0/setup.py   2019-11-08 19:33:37.000000000 
+0100
@@ -10,7 +10,7 @@
 
 setup(
     name='pytest-console-scripts',
-    version='0.1.10',
+    version='0.2.0',
     author='Vasily Kuznetsov',
     author_email='[email protected]',
     maintainer='Vasily Kuznetsov',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/pytest-console-scripts-0.1.10/tests/test_run_scripts.py 
new/pytest-console-scripts-0.2.0/tests/test_run_scripts.py
--- old/pytest-console-scripts-0.1.10/tests/test_run_scripts.py 2019-09-10 
15:17:36.000000000 +0200
+++ new/pytest-console-scripts-0.2.0/tests/test_run_scripts.py  2019-11-08 
19:27:00.000000000 +0100
@@ -98,17 +98,21 @@
     will overwrite the content of the script exposed by this fixture to get
     the behavior that it needs.
     """
-    script = tmpdir_factory.mktemp('script').join('console_script.py')
+    script_dir = tmpdir_factory.mktemp('script')
+    script = script_dir.join('console_script.py')
+    pyc = script_dir.join('console_script.pyc')
+    cache_dir = script_dir.join('__pycache__')
     script.write('def main(): pass')
     pcs_venv.install_console_script('console-script', script)
 
     def replace(new_source):
         """Replace script source."""
         script.write(new_source)
-        pyc = script.strpath + 'c'
-        if os.path.exists(pyc):
-            # Remove stale bytecode that causes heisenbugs on py27.
-            os.remove(pyc)
+        # Remove stale bytecode that causes heisenbugs on py27 and pypy.
+        if pyc.check():
+            pyc.remove()
+        if cache_dir.check():
+            cache_dir.remove(rec=1)
 
     script.replace = replace
     return script
@@ -120,8 +124,8 @@
     return request.param
 
 
[email protected]
-def test_script_in_venv(pcs_venv, console_script, tmpdir, launch_mode):
[email protected]()
+def run_script_in_venv(pcs_venv, console_script, tmpdir, launch_mode):
     """A fixture that tests provided script with provided test."""
 
     def run(script_src, test_src, **kw):
@@ -143,6 +147,21 @@
     return run
 
 
[email protected]()
+def test_script_in_venv(run_script_in_venv):
+    """Tests provided script with provided test and check that it passed."""
+
+    def test(script_src, test_src, **kw):
+        proc = run_script_in_venv(script_src, test_src, **kw)
+        print('--- test run stdout ---')
+        print(proc.stdout.read().decode('utf-8'))
+        print('--- test run stderr ---')
+        print(proc.stderr.read().decode('utf-8'))
+        assert proc.returncode == 0
+
+    return test
+
+
 @pytest.mark.parametrize('script,test', [
     (
         """
@@ -284,9 +303,9 @@
 
 
 @pytest.mark.parametrize('fail', [True, False])
-def test_print_stdio_on_error(test_script_in_venv, fail):
+def test_print_stdio_on_error(run_script_in_venv, fail):
     """Check that the content of stdout and stderr is printed on error."""
-    proc = test_script_in_venv(
+    proc = run_script_in_venv(
         """
 from __future__ import print_function
 
@@ -315,3 +334,25 @@
         assert 'console-script foo' not in stdout
         assert '12345' not in stdout
         assert '54321' not in stdout
+
+
+def test_basic_logging(test_script_in_venv):
+    test_script_in_venv(
+        """
+import logging
+import sys
+
+def main():
+    logging.basicConfig(stream=sys.stderr, level=logging.INFO)
+    logging.debug('hidden')
+    logging.info('shown')
+        """,
+        r"""
+import pytest
+
+def test_env(script_runner):
+    ret = script_runner.run('console-script')
+    assert ret.success
+    assert ret.stderr == 'INFO:root:shown\n'
+        """
+    )


Reply via email to