What are Python properties?

In “What’s the difference between classmethod and staticmethod in Python?” we looked at static and class methods. The third big decorator is the @property decorator import pytest class Person: def __init__(self, name): self._name = name @property def name(self): print(‘Getting name’) return self._name @name.setter def name(self, value): print(f’Setting name to {value}’) self._name = value @name.deleter def…

How to let test cases run in a predefined order

Motivation pytest executes tests in a randomly order. Sometimes it can be useful to have a predefined order in which test cases can run. pytest has a neat plugin for this specific use case. Installation pip install pytest-order Usage import pytest @pytest.mark.order(1) def test_foo(): assert True @pytest.mark.order(2) def test_bar(): assert True @pytest.mark.order(3) def test_foobar(): assert…