简体   繁体   中英

What command does pytest use to run tests files?

I'd like to know how pytest runs test files it finds in a package, so i know what information is available (__name__, __package__, etc) when i try to import modules from the test files.

I tried to take a look at pytest's sources, but they are way too big for a search to be worth it and googling around didn't yield much, so hopefully someone here knows this !

thanks

I would say it depends, in a simple case you are responsible to import the module under test, so you then use the module class/methods or function you want to test in your tests. So pytest execute the test_ files and the imported modules as any python module I would say...

You have example in this get started : https://docs.pytest.org/en/latest/getting-started.html

In a more complexe case, let say, test a webapp, you will need to run the webapp environnement then use selenium for example to browse the app and write tests cases...

But I am not sure I answer your question...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM