88import coloredlogs
99import pytest
1010
11- from Deeploy .Logging import DEFAULT_FMT , DEFAULT_LOGGER as log
11+ from Deeploy .Logging import DEFAULT_FMT
12+ from Deeploy .Logging import DEFAULT_LOGGER as log
1213
1314
1415def pytest_addoption (parser : pytest .Parser ) -> None :
1516 """Native PyTest hook: add custom command-line options for Deeploy tests."""
1617 parser .addoption (
1718 "--skipgen" ,
18- action = "store_true" ,
19- default = False ,
20- help = "Skip network generation step" ,
19+ action = "store_true" ,
20+ default = False ,
21+ help = "Skip network generation step" ,
2122 )
2223 parser .addoption (
2324 "--skipsim" ,
24- action = "store_true" ,
25- default = False ,
26- help = "Skip simulation step (only generate and build)" ,
25+ action = "store_true" ,
26+ default = False ,
27+ help = "Skip simulation step (only generate and build)" ,
2728 )
2829 parser .addoption (
2930 "--toolchain" ,
30- action = "store" ,
31- default = "LLVM" ,
32- help = "Compiler toolchain to use (LLVM or GCC)" ,
31+ action = "store" ,
32+ default = "LLVM" ,
33+ help = "Compiler toolchain to use (LLVM or GCC)" ,
3334 )
3435 parser .addoption (
3536 "--toolchain-install-dir" ,
36- action = "store" ,
37- default = os .environ .get ("LLVM_INSTALL_DIR" ),
38- help = "Path to toolchain installation directory" ,
37+ action = "store" ,
38+ default = os .environ .get ("LLVM_INSTALL_DIR" ),
39+ help = "Path to toolchain installation directory" ,
3940 )
4041 parser .addoption (
4142 "--cmake-args" ,
42- action = "append" ,
43- default = [],
44- help = "Additional CMake arguments (can be used multiple times)" ,
43+ action = "append" ,
44+ default = [],
45+ help = "Additional CMake arguments (can be used multiple times)" ,
4546 )
4647
48+
4749def pytest_configure (config : pytest .Config ) -> None :
4850 """Native PyTest hook: configure pytest for Deeploy tests."""
4951 # Register custom markers
50- config .addinivalue_line (
51- "markers" , "generic: mark test as a Generic platform test"
52- )
53- config .addinivalue_line (
54- "markers" , "kernels: mark test as a kernel test (individual operators)"
55- )
56- config .addinivalue_line (
57- "markers" , "models: mark test as a model test (full networks)"
58- )
59- config .addinivalue_line (
60- "markers" , "slow: mark test as slow running"
61- )
62-
52+ config .addinivalue_line ("markers" , "generic: mark test as a Generic platform test" )
53+ config .addinivalue_line ("markers" , "kernels: mark test as a kernel test (individual operators)" )
54+ config .addinivalue_line ("markers" , "models: mark test as a model test (full networks)" )
55+ config .addinivalue_line ("markers" , "slow: mark test as slow running" )
56+
6357 # Configure logging based on verbosity
6458 verbosity = config .option .verbose
6559 if verbosity >= 3 :
66- coloredlogs .install (level = 'DEBUG' , logger = log , fmt = DEFAULT_FMT )
60+ coloredlogs .install (level = 'DEBUG' , logger = log , fmt = DEFAULT_FMT )
6761 elif verbosity >= 2 :
68- coloredlogs .install (level = 'INFO' , logger = log , fmt = DEFAULT_FMT )
62+ coloredlogs .install (level = 'INFO' , logger = log , fmt = DEFAULT_FMT )
6963 else :
70- coloredlogs .install (level = 'WARNING' , logger = log , fmt = DEFAULT_FMT )
64+ coloredlogs .install (level = 'WARNING' , logger = log , fmt = DEFAULT_FMT )
65+
7166
72- @pytest .fixture (scope = "session" )
67+ @pytest .fixture (scope = "session" )
7368def deeploy_test_dir ():
7469 """Return the DeeployTest directory path."""
7570 return Path (__file__ ).parent
7671
77- @pytest .fixture (scope = "session" )
72+
73+ @pytest .fixture (scope = "session" )
7874def tests_dir (deeploy_test_dir ):
7975 """Return the Tests directory path."""
8076 return deeploy_test_dir / "Tests"
8177
82- @pytest .fixture (scope = "session" )
78+
79+ @pytest .fixture (scope = "session" )
8380def toolchain_dir (request ):
8481 """Return the toolchain installation directory."""
8582 toolchain_install = request .config .getoption ("--toolchain-install-dir" )
8683 if toolchain_install is None :
87- pytest .skip (reason = "LLVM_INSTALL_DIR not set" )
84+ pytest .skip (reason = "LLVM_INSTALL_DIR not set" )
8885 return toolchain_install
8986
90- @pytest .fixture (scope = "session" )
87+
88+ @pytest .fixture (scope = "session" )
9189def ccache_dir ():
9290 """Setup and return ccache directory."""
9391 ccache_path = Path ("/app/.ccache" )
@@ -96,21 +94,25 @@ def ccache_dir():
9694 return ccache_path
9795 return None
9896
97+
9998@pytest .fixture
10099def skipgen (request ):
101100 """Return whether to skip network generation."""
102101 return request .config .getoption ("--skipgen" )
103102
103+
104104@pytest .fixture
105105def skipsim (request ):
106106 """Return whether to skip simulation."""
107107 return request .config .getoption ("--skipsim" )
108108
109+
109110@pytest .fixture
110111def toolchain (request ):
111112 """Return the toolchain to use."""
112113 return request .config .getoption ("--toolchain" )
113114
115+
114116@pytest .fixture
115117def cmake_args (request ):
116118 """Return additional CMake arguments."""
0 commit comments