Fixtures Provided by Test Package#

Pytest package uses fixtures for initializing and customization of tests. You can learn more about fixtures on official pytest documentation as well as see the list of fixtures provided by pytest package itself.

Onetick-py provides separated package for query testing called onetick-py-test, this package is a dependency of onetick-py package, so if the one install onetick-py package they will have access to testing package as will. Onetick-py-test package provides several fixtures for simplifying test creating.

Session fixtures#

Name

Description

f_session

Session with function scope. Previous session will be closed as function will start. Session exists only while function (only one test) is running.

c_session

Session with class scope.

m_session

Session with module (test file) scope.

p_session

Session with package scope.

s_session

Session with pytest session scope. The will be only one Onetick session for all tests.

Folder fixtures#

Name

Description

cur_dir

Returns absolute path to the folder with the test.

par_dir

Returns absolute path to the parent folder of the test.

product_dir

Returns absolute path to the nearest product parent directory. The search is starting from the path directory and moving to a parent folders. If a parent folder contains necessary files and subdirectories, then the function returns absolute path to that directory; if it reaches the root ‘/’, then the error will be raised.

no_ex_product_dir

Returns absolute path to the nearest product parent directory. The search is starting from the path directory and moving to a parent folders. If a parent folder contains necessary files and subdirectories, then the function returns absolute path to that directory; if it reaches the root ‘/’, then the function returns “None”.

client_dir

Returns absolute path to the nearest client_data parent directory. The search is starting from the path directory and moving to a parent folders. If a parent folder contains necessary files and subdirectories, then the function returns absolute path to that directory; if it reaches the root ‘/’, then the error will be raised.

no_ex_client_dir

Returns absolute path to the nearest client_data parent directory. The search is starting from the path directory and moving to a parent folders. If a parent folder contains necessary files and subdirectories, then the function returns absolute path to that directory; if it reaches the root ‘/’, then the function returns “None”.

keep_generated_dir

Returns absolute path to the folder were test will be saved if keep-generated flag was specified.