Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests for pytest6.x, cherrypy/test/test_config.py::ConfigTests::testHandlerToolConfigOverride and cherrypy/test/test_caching.py::CacheTest::testGzipStaticCache #1897

Merged
merged 2 commits into from
Jan 17, 2021

Conversation

a16bitsysop
Copy link
Contributor

@a16bitsysop a16bitsysop commented Jan 15, 2021

What kind of change does this PR introduce?

  • bug fix
  • feature
  • docs update
  • tests/coverage improvement
  • refactoring
  • other

What is the related issue number (starting with #)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Stops two test failures with pytest6.x

Other information:

Checklist:

  • I think the code is well written
  • I wrote good commit messages
  • I have squashed related commits together after the changes have been approved
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • I used the same coding conventions as the rest of the project
  • The new code doesn't generate linter offenses
  • Documentation reflects the changes
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences

@@ -221,8 +221,9 @@ def testHandlerToolConfigOverride(self):
# the favicon in the page handler to be '../favicon.ico',
# but then overrode it in config to be './static/dirback.jpg'.
self.getPage('/favicon.ico')
self.assertBody(open(os.path.join(localDir, 'static/dirback.jpg'),
'rb').read())
testfile = open(os.path.join(localDir, 'static/dirback.jpg'),'rb')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use a CM (with) in order to guarantee that the file descriptor gets closed always.

@@ -70,6 +70,10 @@ def __next__(self):
raise StopIteration()
next = __next__

def __del__(self):
"""Close input on descturct"""
self.input.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should follow the same "if hasattr" approach as above.

@@ -70,6 +70,10 @@ def __next__(self):
raise StopIteration()
next = __next__

def __del__(self):
"""Close input on descturct"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP257-compliant docstrings should end with a period.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a16bitsysop a16bitsysop changed the title fix some tests for pytest6.x fix tests for pytest6.x, cherrypy/test/test_config.py::ConfigTests::testHandlerToolConfigOverride and cherrypy/test/test_caching.py::CacheTest::testGzipStaticCache Jan 15, 2021
Comment on lines +224 to +225
with open(os.path.join(localDir, 'static/dirback.jpg'), 'rb') as tf:
self.assertBody(tf.read())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd probably be cleaner with pathlib API. But it doesn't matter now. Just something to keep in mind for the future.

@webknjaz
Copy link
Member

I think I need to apply put ignores in the pytest config and then address the warnings one by one... Ref cherrypy/cheroot@3eebb80

@webknjaz
Copy link
Member

I'll rebase this PR meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants