Skip to content

Instantly share code, notes, and snippets.

@audiolion
Last active March 24, 2023 01:34
Show Gist options
  • Save audiolion/fcba115f74b99d980bd6124f4b051fd6 to your computer and use it in GitHub Desktop.
Save audiolion/fcba115f74b99d980bd6124f4b051fd6 to your computer and use it in GitHub Desktop.
pytest assert vs self.assertEqual
class TestSomething(TestCase):
def test_something(self):
assert something['message'] == 'Asserting that a very long message statement is as expected in this test case here, the issue is that its all on one line with no easy way to conform to PEP-8 besides adding "\" to continue the one line statement in python.'
self.assertEqual(
something['message'],
('Asserting that a very long message statement is as expected'
' in this test case here, the issue is that its all on one line'
' with no easy way to conform to PEP-8 besides adding "\" to'
' continue the one line statement in python.'
' With assertEqual and the function structure we can easily'
' break up a long assert statement to make it readable and'
' PEP-8 compliant.')
)
@acurvers
Copy link

would you recommend to always use pytest assert ?

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