gabrielfalcao / HTTPretty

Intercept HTTP requests at the Python socket level. Fakes the whole socket module
https://httpretty.readthedocs.org
MIT License
2.11k stars 276 forks source link

Fallback to WARNING when logging.getLogger().level is None #435

Closed hroncok closed 3 years ago

hroncok commented 3 years ago

We see the following errors in cloud-init that this solves:

tests/unittests/test_data.py:66: in setUp
    super(TestConsumeUserData, self).setUp()
cloudinit/tests/helpers.py:245: in setUp
    super(FilesystemMockingTestCase, self).setUp()
cloudinit/tests/helpers.py:230: in setUp
    super(ResourceUsingTestCase, self).setUp()
cloudinit/tests/helpers.py:362: in setUp
    httpretty.enable()
/usr/lib/python3.9/site-packages/httpretty/core.py:1818: in enable
    logger.setLevel(logging.getLogger().level)
/usr/lib64/python3.9/logging/__init__.py:1421: in setLevel
    self.level = _checkLevel(level)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
level = None
    def _checkLevel(level):
        if isinstance(level, int):
            rv = level
        elif str(level) == level:
            if level not in _nameToLevel:
                raise ValueError("Unknown level: %r" % level)
            rv = _nameToLevel[level]
        else:
>           raise TypeError("Level not an integer or a valid string: %r" % level)
E           TypeError: Level not an integer or a valid string: None
/usr/lib64/python3.9/logging/__init__.py:201: TypeError
sshedi commented 3 years ago

@gabrielfalcao - can you please merge this PR and make a new release? this is breaking cloud-init make checks

gabrielfalcao commented 3 years ago

Thanks for the patch @hroncok and @sshedi for pinging me!

gabrielfalcao commented 3 years ago

Patch released in version 1.1.4