-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unit_Test_nose_tests_setup
113 lines (76 loc) · 3.64 KB
/
Unit_Test_nose_tests_setup
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
PyEZ unit test execution :
nose tests:
python -m pip install nose
python -m pip install mock
python -m pip install coverage
python -m pip install ntc_templates==1.4.1
python -m pip install textfsm==0.4.1
To run the pyez unit tests :
cd py-junos-eznc/tests/unit
nosetests -v --with-coverage --cover-package=jnpr.junos --cover-inclusive -a unit
To run jsnapy unit tests
cd tests/unit
nosetests -v --with-coverage --cover-package=jnpr.jsnapy --cover-inclusive -a unit
To check compilation errors
find . -iname '*.py' | xargs -P4 -I{} python3.7 -Wall -m py_compile {}
To run functional tests
nosetests -v --with-xunit --xunit-file=functionaltests.xml --with-coverage --cover-package=jnpr.junos --cover-xml --cover-inclusive --cover-erase test_config.py test_core.py test_exception.py test_file_ftp.py test_file_scp.py test_route_table.py test_rpc.py test_route_table.py test_shell.py test_table_present.py test_telnet.py test_utils_sw.py
nosetests -v --with-xunit --xunit-file=functionaltests.xml --with-coverage --cover-package=jnpr.junos --cover-xml --cover-inclusive --cover-erase test_utils_file_system
cd /root/pyez/py-junos-eznc/tests/unit
nosetests -v *
UT/FT execution on windows:
tests\unit
nosetests.exe -v .\test_check.py
nosetests.exe -v .\test_comparison_op.py
nosetests.exe -v .\test_init.py
nosetests.exe -v .\test_jsnapy.py
nosetests.exe -v .\test_notify.py
nosetests.exe -v .\test_numeric_op.py
nosetests.exe -v .\test_operator.py
nosetests.exe -v .\test_snap.py
nosetests.exe -v .\test_snap_new.py
nosetests.exe -v .\test_sqlite.py
nosetests.exe -v .\test_string_op.py
nosetests.exe -v .\test_str_numeric_op.py
Nosetest debugging:
To set breakpoints
from nose.tools import set_trace; set_trace()
/root/sw_install_member/py-junos-eznc/tests/unit/utils
nosetests -v ./test_sw.py:TestSW
Python3.10:
AttributeError: module 'collections' has no attribute 'Callable'
pip uninstall -y nose
pip install -U nose --no-binary :all:
https://github.com/nose-devs/nose/issues/1099
nose2:
nose2 tests:
python -m pip install nose2
nose2 -v --coverage jnpr.junos --with-coverage
nose2 -v --coverage jnpr.junos
python -m pip install nose2[coverage_plugin]
To run functional tests:
(venv) root@masterhost:~/pyez_release_test1/py-junos-eznc# cat nose2.cfg
[unittest]
start-dir=./
(venv) root@masterhost:~/pyez_release_test1/py-junos-eznc# nose2 -v -c nose2.cfg
(venv) root@masterhost:~/pyez_release_test1/py-junos-eznc# cat tests/functional/nose2.cfg
[unittest]
start-dir=./
(venv) root@masterhost:~/pyez_release_test1/py-junos-eznc# cat nose2.cfg
[unittest]
start-dir=./tests/functional
(venv) root@masterhost:~/pyez_release_test1/py-junos-eznc# ls tests/functional/
config.yaml protocol_data.yml test_config.py test_file_scp.py test_sshConfigure.py test_utils_sw.py
coverage.xml protocol_temp.j2 test_core.py test_route_table.py test_table_present.py
functionaltests.xml __pycache__ test_device_ssh.py test_rpc.py test_table.py
__init__.py random test_exception.py test.sh test_telnet.py
nose2.cfg skip_version.py test_file_ftp.py test_shell.py test_utils_file_system.py
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/subprocess.py:935: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
self.stdin = io.open(p2cwrite, 'wb', bufsize)
https://github.com/yadage/packtivity/pull/78/files
Fix for Unit test faliures:
Fix1:
python -m pip install ntc_templates==1.4.1
python -m pip install textfsm==0.4.1
Fix2:
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html