News for hackers. Stuff that matters.
Re:Show HN: Python Tests That Write Themselves by timothycrosley on Wednesday September 18, 2019 @11:45AM (#21006564)
Hi @kburman,

For cases like that it would be best combined with a mock:

  @auto_pytest()
  def test_add(test_case, mocker):
      mocker.patch('db.call')
      test_case()
Note that this example utilizes the following pytest extension: https://github.com/pytest-dev/pytest-mock

However, I would also note, that just because you have some methods that have potentially dangerous side effects, in most large code-bases, not all functions do. Which is why it operates at a function by function basis. You can use this for new pure functions, while continuing to write other tests in the same fashion by hand.

There are no comments on this comment yet.