Skip to content

Failures with Python 3.8 #755

Closed
Closed

Description

@hroncok

In Fedora, we have the following failures with behave 1.2.6 and Python 3.8.0b1:


==================================== ERRORS ====================================
_ ERROR at setup of TestCaptureController.test_capturing__retrieve_captured_several_times _

    @pytest.fixture
    def capture_controller():
        """Provides a capture_controller that is already setup and automatically
        performs a teardown afterwards.
        """
        capture_controller = create_capture_controller()
>       setup_capture_controller(capture_controller)

tests/unit/test_capture.py:42: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/unit/test_capture.py:30: in setup_capture_controller
    capture_controller.setup_capture(context)
behave/capture.py:147: in setup_capture
    self.log_capture = LoggingCapture(self.config)
behave/log_capture.py:74: in __init__
    formatter = logging.Formatter(log_format, datefmt)
/usr/lib64/python3.8/logging/__init__.py:576: in __init__
    self._style.validate()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <logging.PercentStyle object at 0x7f4272b01700>

    def validate(self):
        """Validate the input format, ensure it matches the correct style"""
>       if not self.validation_pattern.search(self._fmt):
E       TypeError: expected string or bytes-like object

/usr/lib64/python3.8/logging/__init__.py:428: TypeError
_ ERROR at setup of TestCaptureController.test_capturing__with_several_start_stop_cycles _

    @pytest.fixture
    def capture_controller():
        """Provides a capture_controller that is already setup and automatically
        performs a teardown afterwards.
        """
        capture_controller = create_capture_controller()
>       setup_capture_controller(capture_controller)

tests/unit/test_capture.py:42: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/unit/test_capture.py:30: in setup_capture_controller
    capture_controller.setup_capture(context)
behave/capture.py:147: in setup_capture
    self.log_capture = LoggingCapture(self.config)
behave/log_capture.py:74: in __init__
    formatter = logging.Formatter(log_format, datefmt)
/usr/lib64/python3.8/logging/__init__.py:576: in __init__
    self._style.validate()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <logging.PercentStyle object at 0x7f4271516190>

    def validate(self):
        """Validate the input format, ensure it matches the correct style"""
>       if not self.validation_pattern.search(self._fmt):
E       TypeError: expected string or bytes-like object

/usr/lib64/python3.8/logging/__init__.py:428: TypeError
_______ ERROR at setup of TestCaptureController.test_make_capture_report _______

    @pytest.fixture
    def capture_controller():
        """Provides a capture_controller that is already setup and automatically
        performs a teardown afterwards.
        """
        capture_controller = create_capture_controller()
>       setup_capture_controller(capture_controller)

tests/unit/test_capture.py:42: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/unit/test_capture.py:30: in setup_capture_controller
    capture_controller.setup_capture(context)
behave/capture.py:147: in setup_capture
    self.log_capture = LoggingCapture(self.config)
behave/log_capture.py:74: in __init__
    formatter = logging.Formatter(log_format, datefmt)
/usr/lib64/python3.8/logging/__init__.py:576: in __init__
    self._style.validate()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <logging.PercentStyle object at 0x7f4271520100>

    def validate(self):
        """Validate the input format, ensure it matches the correct style"""
>       if not self.validation_pattern.search(self._fmt):
E       TypeError: expected string or bytes-like object

/usr/lib64/python3.8/logging/__init__.py:428: TypeError
=================================== FAILURES ===================================
____________ TestRunWithPaths.test_loads_hooks_and_step_definitions ____________

self = <test.test_runner.TestRunWithPaths testMethod=test_loads_hooks_and_step_definitions>

    def test_loads_hooks_and_step_definitions(self):
        self.feature_locations.return_value = []
>       self.runner.run_with_paths()

test/test_runner.py:678: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
behave/runner.py:824: in run_with_paths
    return self.run_model()
behave/runner.py:613: in run_model
    self.setup_capture()
behave/runner.py:590: in setup_capture
    self.capture_controller.setup_capture(self.context)
behave/capture.py:147: in setup_capture
    self.log_capture = LoggingCapture(self.config)
behave/log_capture.py:74: in __init__
    formatter = logging.Formatter(log_format, datefmt)
/usr/lib64/python3.8/logging/__init__.py:576: in __init__
    self._style.validate()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <logging.PercentStyle object at 0x7f4272ac0610>

    def validate(self):
        """Validate the input format, ensure it matches the correct style"""
>       if not self.validation_pattern.search(self._fmt):
E       TypeError: expected string or bytes-like object

/usr/lib64/python3.8/logging/__init__.py:428: TypeError
____ TestRunWithPaths.test_parses_feature_files_and_appends_to_feature_list ____

self = <test.test_runner.TestRunWithPaths testMethod=test_parses_feature_files_and_appends_to_feature_list>
abspath = <MagicMock name='abspath' id='139923345085536'>
parse_file = <MagicMock name='parse_file' id='139923345946176'>

    @patch("behave.parser.parse_file")
    @patch("os.path.abspath")
    def test_parses_feature_files_and_appends_to_feature_list(self, abspath,
                                                              parse_file):
        feature_locations = ["one", "two", "three"]
        feature = Mock()
        feature.tags = []
        feature.__iter__ = Mock(return_value=iter([]))
        feature.run.return_value = False
        self.runner.feature_locations.return_value = feature_locations
        abspath.side_effect = lambda x: x.upper()
        self.config.lang = "fritz"
        self.config.format = ["plain"]
        self.config.outputs = [StreamOpener(stream=sys.stdout)]
        self.config.output.encoding = None
        self.config.exclude = lambda s: False
        self.config.junit = False
        self.config.summary = False
        parse_file.return_value = feature
    
>       self.runner.run_with_paths()

test/test_runner.py:717: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
behave/runner.py:824: in run_with_paths
    return self.run_model()
behave/runner.py:613: in run_model
    self.setup_capture()
behave/runner.py:590: in setup_capture
    self.capture_controller.setup_capture(self.context)
behave/capture.py:147: in setup_capture
    self.log_capture = LoggingCapture(self.config)
behave/log_capture.py:74: in __init__
    formatter = logging.Formatter(log_format, datefmt)
/usr/lib64/python3.8/logging/__init__.py:576: in __init__
    self._style.validate()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <logging.PercentStyle object at 0x7f4272a95d00>

    def validate(self):
        """Validate the input format, ensure it matches the correct style"""
>       if not self.validation_pattern.search(self._fmt):
E       TypeError: expected string or bytes-like object

/usr/lib64/python3.8/logging/__init__.py:428: TypeError
__________ TestRunWithPaths.test_runs_before_all_and_after_all_hooks ___________

self = <test.test_runner.TestRunWithPaths testMethod=test_runs_before_all_and_after_all_hooks>

    def test_runs_before_all_and_after_all_hooks(self):
        # Make runner.feature_locations() and runner.run_hook() the same mock so
        # we can make sure things happen in the right order.
        self.runner.feature_locations = self.run_hook
        self.runner.feature_locations.return_value = []
        self.runner.context = Mock()
>       self.runner.run_with_paths()

test/test_runner.py:689: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
behave/runner.py:824: in run_with_paths
    return self.run_model()
behave/runner.py:613: in run_model
    self.setup_capture()
behave/runner.py:590: in setup_capture
    self.capture_controller.setup_capture(self.context)
behave/capture.py:147: in setup_capture
    self.log_capture = LoggingCapture(self.config)
behave/log_capture.py:74: in __init__
    formatter = logging.Formatter(log_format, datefmt)
/usr/lib64/python3.8/logging/__init__.py:576: in __init__
    self._style.validate()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <logging.PercentStyle object at 0x7f4271395e20>

    def validate(self):
        """Validate the input format, ensure it matches the correct style"""
>       if not self.validation_pattern.search(self._fmt):
E       TypeError: expected string or bytes-like object

/usr/lib64/python3.8/logging/__init__.py:428: TypeError
______________________ TestCaptureController.test_basics _______________________

self = <tests.unit.test_capture.TestCaptureController object at 0x7f4271439880>

    def test_basics(self):
        capture_controller = create_capture_controller()
        context = Mock()
        context.aborted = False
        context.config = capture_controller.config
    
>       capture_controller.setup_capture(context)

tests/unit/test_capture.py:226: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
behave/capture.py:147: in setup_capture
    self.log_capture = LoggingCapture(self.config)
behave/log_capture.py:74: in __init__
    formatter = logging.Formatter(log_format, datefmt)
/usr/lib64/python3.8/logging/__init__.py:576: in __init__
    self._style.validate()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <logging.PercentStyle object at 0x7f42719918b0>

    def validate(self):
        """Validate the input format, ensure it matches the correct style"""
>       if not self.validation_pattern.search(self._fmt):
E       TypeError: expected string or bytes-like object

/usr/lib64/python3.8/logging/__init__.py:428: TypeError

Full log: builder.log

Activity

  1. tirkarthi commented on Jun 8, 2019

    @tirkarthi

    Seems to be due to python/cpython#9703 . Formatter could pass validate=False to have the old behavior but it be good to have this fixed instead of restoring the older behavior.

  2. jenisys commented on Jun 9, 2019

    @jenisys
    Member

    Partially fixed (on current HEAD), meaning unit test suite runs again without errors:

    • logging.Formatter.validate() problem (caused by: Mock() object in test suite)
    • @asyncio.coroutine usage: Decorator is deprecated since Python 3.8

    Other issues (warnings, ...) still need to be addressed.

  3. added a commit that references this issue on Jun 9, 2019
  4. added a commit that references this issue on Jul 7, 2019
  5. jenisys commented on Jul 7, 2019

    @jenisys
    Member

    INTEGRATED INTO: behave-1.2.7.dev1

  6. mbanck commented on Jan 24, 2020

    @mbanck

    What is the commit that fixed this? There does not seem to have been a stable release since, so distribution will have to cherry-pick this in order to support behave on python3.8.

  7. mbanck commented on Jan 24, 2020

    @mbanck

    Cool! Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions