christianhelle / autofaker

Python library designed to minimize the setup/arrange phase of your unit tests
MIT License
6 stars 3 forks source link

pytest support #2

Closed vabc3 closed 2 years ago

vabc3 commented 2 years ago

This is a very helpful project. Cannot imagine there is no AutoFixture correspondence in python.

It would be more useful if there is pytest support:

from autofaker import autodata
@autodata()
def test_2(tstr: str):
  pass

Output: NotImplementedError: This way of creating anonymous objects are only supported from unit test

christianhelle commented 2 years ago

Thanks for your kind words! This was a learning project for me while getting started with Python :)

I'll see what I can do regarding pytest

christianhelle commented 2 years ago

I started work on this and the branch pytest-support already supports the sample test you posted

from autofaker import autodata
@autodata()
def test_create_str_using_decorator(text: str):
  assert text is not None

I'm adding a few more comprehensive test cases so I'm sure I don't introduce breaking changes

christianhelle commented 2 years ago

@vabc3 I implemented this request and will release it to PyPi as soon as I update the docs, sample code, and resolve SonarCloud issues

christianhelle commented 2 years ago

This is now release to PyPi as AutoFaker v0.4.9

vabc3 commented 2 years ago

Just tried the new release, it works perfectly. Thanks for the great work, that's so cool.