Pro Python Best Practices by Kristian Rother

Pro Python Best Practices by Kristian Rother

Author:Kristian Rother
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


class TestCrateMoves:

def test_move_to_none(self)

def test_paths(self, path, level)

def test_move_player(self, level, path, expected_x, expected_y)

A test class behaves like a normal Python class. We don’t need to write a constructor (_init_) or instantiate the class: py.test will take care of that for us. With [NEWLINE]from fixtures import level, LEVEL[NEWLINE] makes the tests pass.

Hint

If you are familiar with unittest , the test framework of the standard Python library, you might expect us to create a subclass of unittest.TestCase. You still can do that when using py.test , and all assertion methods from unittest work in the same way. Here we are going to implement all tests using py.test assertions instead (which is incompatible with unittest-style classes). The resulting code is a little shorter and easier to read.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.