I have recommended Bruno's solution several times. 
Same model works with unittest. 
If Ronny's idea moves forward I'd rather see that as a plugin than in core if 
possible. 

- Brian

> On Aug 31, 2016, at 10:48 AM, Bruno Oliveira <[email protected]> wrote:
> 
> Hi Ronny,
> 
> We’ve had the same need at work, although it seems in a smaller scale than 
> yours. This is the approach we took:
> 
> Shared tests are always in classes without a Test prefix so they won’t be 
> collected. Those base classes may be then subclassed in different projects 
> and implement the required fixtures:
> 
> # file in a "base project" somewhere
> class BaseSerializerTests:
> 
>     @pytest.fixture
>     def serializer(self):
>         assert 0, 'implement fixture in your subclass'
> 
>     def test_dump(serializer):
>         d = {'data': 1}
>         assert serializer.loads(serializer.dumps(d)) == d
> 
>     def test_numericals(serializer):
>         assert serializer.loads(serializer.dumps(99)) == 99
> # file in "json" project somewhere
> from base_project import BaseSerializerTests
> 
> class TestJSONSerializer(BaseSerializerTests):
> 
>     @pytest.fixture
>     def serializer(self):
>         return JSONSerializer()
> # file in "hdf" project somewhere
> from base_project import BaseSerializerTests
> 
> class TestHDFSerializer(BaseSerializerTests):
> 
>     @pytest.fixture
>     def serializer(self, tmpdir):
>         return HDFSerializer(tmpdir.join('test.hdf'))
> The advantages are that we don’t need to customize pytest at all and tests 
> added to the base test classes propagate naturally to the subclasses in other 
> projects. Also, each fixture is free to depend on other fixtures naturally, 
> like tmpdir on the second example.
> 
> Not sure if the above scales for your company thought.
> 
> Back to your proposal: can’t it be implemented as a plugin instead of in the 
> core?
> 
> Cheers,
> Bruno.
> 
> 
>> On Wed, Aug 31, 2016 at 2:37 PM Ronny Pfannschmidt <[email protected]> 
>> wrote:
>> Hi everyone,
>> 
>> at work i am hitting a problem where tests have to be shared between teams, 
>> while fixtures may differ
>> 
>> in order to ease that i came up with a initial idea for specifying where to 
>> look for tests in pytest.ini
>> 
>> 
>> example:
>> [pytest]
>> collect_roots=
>>   base=module://framework.basetests
>>   myteam=file://./test/
>> 
>> 
>> with a default value of 
>> 
>> collect_roots=
>>   . = file://.
>> 
>> 
>> the specification would give the possibility to make test suite repos 
>> and import test suites
>> 
>>   
>> 
>> -- 
>> Red Hat GmbH, http://www.de.redhat.com/, Registered seat: Grasbrunn, 
>> Commercial register: Amtsgericht Muenchen, HRB 153243,
>> Managing Directors: Charles Cachera, Michael Cunningham, Michael O'Neill, 
>> Eric Shander
>> _______________________________________________
>> pytest-dev mailing list
>> [email protected]
>> https://mail.python.org/mailman/listinfo/pytest-dev
> _______________________________________________
> pytest-dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/pytest-dev
_______________________________________________
pytest-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to