-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-pytest.bat
68 lines (55 loc) · 2.42 KB
/
run-pytest.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@echo off
:: Define file paths
set base_dir_pytest_result=".\result\pytest"
set base_dir_pytest_result_readme=".\result\pytest\README.md"
set "testing_file_txt=.\result\pytest\text\report.txt"
set "testing_file_txt_dir=.\result\pytest\text\"
set "testing_file_html_dir=.\result\pytest\html"
:: Create directory if it doesn't exist
if not exist "%base_dir_pytest_result%" (
mkdir "%base_dir_pytest_result%"
)
if not exist "%testing_file_txt_dir%" (
mkdir "%testing_file_txt_dir%"
)
:: Get date
for /f "tokens=2 delims==" %%D in ('wmic Path Win32_LocalTime Get Day /Format:value') do set "day=%%D"
for /f "tokens=2 delims==" %%M in ('wmic Path Win32_LocalTime Get Month /Format:value') do set "month=%%M"
for /f "tokens=2 delims==" %%Y in ('wmic Path Win32_LocalTime Get Year /Format:value') do set "year=%%Y"
for /f "tokens=2 delims==" %%W in ('wmic Path Win32_LocalTime Get DayOfWeek /Format:value') do set "dow=%%W"
:: Get time
for /f "tokens=2 delims==" %%H in ('wmic Path Win32_LocalTime Get Hour /Format:value') do set "HH=%%H"
for /f "tokens=2 delims==" %%N in ('wmic Path Win32_LocalTime Get Minute /Format:value') do set "MM=%%N"
for /f "tokens=2 delims==" %%S in ('wmic Path Win32_LocalTime Get Second /Format:value') do set "SS=%%S"
:: Map day of the week number to name
set "dow_name=Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
for /f "tokens=%dow% delims= " %%D in ("%dow_name%") do set "dow=%%D"
:: Additional information
:: Ownership notice
(
echo.
echo * coverage pytest dir
echo * coverage testing date: %year%/%month%/%day%/ %dow%
echo * coverage testing time: %HH%:%MM%:%SS%
echo * operation: pytest result
echo * author: alisharify7
echo * Copyright 2025.
echo * under GNU General Public License v3.0
echo * https://github.com/free-programmers/python-testing-suite-script
echo.
) > "%base_dir_pytest_result_readme%"
(
echo.
echo * coverage pytest dir
echo * coverage testing date: %year%/%month%/%day%/ %dow%
echo * coverage testing time: %HH%:%MM%:%SS%
echo * operation: pytest result
echo * author: alisharify7
echo * Copyright 2025.
echo * under GNU General Public License v3.0
echo * https://github.com/free-programmers/python-testing-suite-script
echo.
) > "%testing_file_txt%"
:: Run pytest and append the result to the file
pytest -v >> %testing_file_txt%
pytest --html="%testing_file_html_dir%\report.html" --self-contained-html