pytest is a test framework, right? and framework is a set of rules to enforce, otherwise, what is it? all IMHO of course, please don't take it too serious, it's mostly my experience with fixtures in pytest: if something is not a fixture, then you'll have a problem at some point
On 25 September 2014 14:31, Jens Hoffmann <[email protected]> wrote: > Okay, I clearly get what Guido said, but I say: let the folks do what > they want to! pytest now kind of forces me to think like Guido; > > > Jens > > > > > On 09/25/2014 02:23 PM, Anatoly Bubenkov wrote: > > exactly, just throw away all those classes - Guido said, classes are NOT > namespaces > you might only need classes for the polymorphism, but it's no-use in the > tests > > On 25 September 2014 14:20, Jens Hoffmann <[email protected]> wrote: > >> This gives me a little pain, since I always liked to organize my tests >> OO-like, with classes etc; the docs call pytest fixtures: explicit, >> modular, scalable; but for me "decorating classes and methods" is a tiny >> bit of magic that forces me to leave the pure OO way and to think a little >> more functional; >> >> >> Jens >> >> >> >> On 09/25/2014 02:09 PM, Anatoly Bubenkov wrote: >> >> the thing is, fixtures have proper dependency injection working >> but combing them with oldish setup_ methods doesn't always work properly >> out of the box - just because it's impossible to determine the 'right' >> order, because there's no 'right' order, it's all up to you to determine >> the dependency tree >> >> On 25 September 2014 14:06, Jens Hoffmann <[email protected]> wrote: >> >>> okay, I'll kill them... thank you for your quick responses >>> >>> >>> >>> On 09/25/2014 02:03 PM, Anatoly Bubenkov wrote: >>> >>> setup_ methods should just die :) >>> use fixtures everywhere instead >>> >>> On 25 September 2014 14:01, Jens Hoffmann <[email protected]> wrote: >>> >>>> Okay, writing the example I found out what the actual problem is: >>>> >>>> >>>> In the minimal example the fixture *is* executed, before any test but >>>> *after* my test classes setup_method. >>>> >>>> >>>> I though expect that a session fixture is executed also before a >>>> classes setup_method (use case: fixture sets up DB, setup_method sets up >>>> some tables); >>>> >>>> >>>> Am I wrong? >>>> >>>> >>>> Jens >>>> >>>> >>>> >>>> On 09/25/2014 01:18 PM, Anatoly Bubenkov wrote: >>>> >>>> please upload fully reproducable small example somewhere >>>> or, ideally, create a test and have a PR with it >>>> >>>> On 25 September 2014 13:14, Jens Hoffmann <[email protected]> wrote: >>>> >>>>> Yes, the directories test and test/module all contain a __init__.py; >>>>> sorry, that I didnt mention this important info. >>>>> >>>>> So from your question I guess that you expect py.test to find and >>>>> execute conftest.py in all the cases shown? >>>>> >>>>> >>>>> Jens >>>>> >>>>> >>>>> >>>>> On 09/25/2014 01:09 PM, Anatoly Bubenkov wrote: >>>>> >>>>> did you add __init__.py in all folders? >>>>> >>>>> On 25 September 2014 12:35, Jens Hoffmann <[email protected]> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> >>>>>> we are working with pytest 2.6.2 and I run into a problem with my >>>>>> conftest session fixture setup. >>>>>> >>>>>> My project structure looks something like this: >>>>>> >>>>>> . >>>>>> ├── project >>>>>> │ └── module >>>>>> │ └── foo.py >>>>>> └── test >>>>>> ├── conftest.py >>>>>> └── module >>>>>> └── test_foo.py >>>>>> >>>>>> >>>>>> conftest.py contains a single fixture with scope="session" and >>>>>> autouse=True, setting up some database that is needed for every single >>>>>> unittest. So also test_foo.py depends on that database setup. >>>>>> >>>>>> Now some py.test runs: >>>>>> >>>>>> $ py.test >>>>>> => conftest.py called, database setup properly, tests pass >>>>>> >>>>>> $ py.test test/module >>>>>> => tests fail, fixture in conftest.py not executed >>>>>> >>>>>> $ py.test test/module/test_foo.py >>>>>> => tests fail, fixture in conftest.py not executed >>>>>> >>>>>> $ py.test -k MyTestClassContainedInTestFooDotPy >>>>>> => tests fail, fixture in conftest.py not executed >>>>>> >>>>>> >>>>>> Now my question/problem: Are all these outcoms expected behaviour? I >>>>>> hoped that all the runs would pass, that is execute my session fixture so >>>>>> that I wont need to always run my whole test suite. >>>>>> >>>>>> >>>>>> Thank you for your answer, >>>>>> Jens >>>>>> >>>>>> _______________________________________________ >>>>>> Pytest-dev mailing list >>>>>> [email protected] >>>>>> https://mail.python.org/mailman/listinfo/pytest-dev >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Anatoly Bubenkov >>>>> >>>>> >>>>> -- >>>>> Jens Hoffmann Softwareentwickler Datamanagement billiger.de solute >>>>> gmbh Zeppelinstraße 15 D-76185 Karlsruhe Tel: +49 (0)721 - 86956-24 >>>>> <%2B49%20%280%29721%20-%2086956-24> Fax: +49 (0)721 - 86956-66 >>>>> <%2B49%20%280%29721%20-%2086956-66> E-Mail: [email protected] Web: >>>>> http://www.billiger.de Geschäftsführer: Lorenz Petersen Sitz: >>>>> Karlsruhe Registergericht: Amtsgericht Mannheim Registernummer: HRB 110579 >>>>> Umsatzsteueridentifikationsnummer: DE234663798 >>>>> http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png >>>>> >>>> >>>> >>>> >>>> -- >>>> Anatoly Bubenkov >>>> >>>> >>>> -- >>>> Jens Hoffmann Softwareentwickler Datamanagement billiger.de solute >>>> gmbh Zeppelinstraße 15 D-76185 Karlsruhe Tel: +49 (0)721 - 86956-24 >>>> <%2B49%20%280%29721%20-%2086956-24> Fax: +49 (0)721 - 86956-66 >>>> <%2B49%20%280%29721%20-%2086956-66> E-Mail: [email protected] Web: >>>> http://www.billiger.de Geschäftsführer: Lorenz Petersen Sitz: >>>> Karlsruhe Registergericht: Amtsgericht Mannheim Registernummer: HRB 110579 >>>> Umsatzsteueridentifikationsnummer: DE234663798 >>>> http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png >>>> >>> >>> >>> >>> -- >>> Anatoly Bubenkov >>> >>> >>> -- >>> Jens Hoffmann Softwareentwickler Datamanagement billiger.de solute gmbh >>> Zeppelinstraße 15 D-76185 Karlsruhe Tel: +49 (0)721 - 86956-24 >>> <%2B49%20%280%29721%20-%2086956-24> Fax: +49 (0)721 - 86956-66 >>> <%2B49%20%280%29721%20-%2086956-66> E-Mail: [email protected] Web: >>> http://www.billiger.de Geschäftsführer: Lorenz Petersen Sitz: Karlsruhe >>> Registergericht: Amtsgericht Mannheim Registernummer: HRB 110579 >>> Umsatzsteueridentifikationsnummer: DE234663798 >>> http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png >>> >> >> >> >> -- >> Anatoly Bubenkov >> >> >> -- >> Jens Hoffmann Softwareentwickler Datamanagement billiger.de solute gmbh >> Zeppelinstraße 15 D-76185 Karlsruhe Tel: +49 (0)721 - 86956-24 >> <%2B49%20%280%29721%20-%2086956-24> Fax: +49 (0)721 - 86956-66 >> <%2B49%20%280%29721%20-%2086956-66> E-Mail: [email protected] Web: >> http://www.billiger.de Geschäftsführer: Lorenz Petersen Sitz: Karlsruhe >> Registergericht: Amtsgericht Mannheim Registernummer: HRB 110579 >> Umsatzsteueridentifikationsnummer: DE234663798 >> http://cdn.billiger.com/static/mail/billiger_today_logo_dunkel_20140911.png >> > > > > -- > Anatoly Bubenkov > > > -- > Jens Hoffmann Softwareentwickler billiger.de solute gmbh > _______________________________________________________________ > [email protected] http://www.billiger.de http://www.solute.de > _______________________________________________________________ Office > Karlsruhe Zeppelinstraße 15 D-76185 Karlsruhe Tel: ... Fax: ... > _______________________________________________________________ > Geschäftsführer: Lorenz Petersen Sitz: Karlsruhe Registergericht: > Amtsgericht Mannheim Registernummer: HRB 110579 > Umsatzsteueridentifikationsnummer: DE234663798 > -- Anatoly Bubenkov
_______________________________________________ Pytest-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pytest-dev
