svinota / pyroute2

Python Netlink and PF_ROUTE library — network configuration and monitoring
https://pyroute2.org/
Other
949 stars 243 forks source link

Unable to run pyroute2 unit test with setup.py #778

Open prashant1221 opened 3 years ago

prashant1221 commented 3 years ago

After building pyroute2-0.5.17 using python3 setup.py build. I am trying to run unit tests using python3 setup.py test. This throws error:

running test running egg_info writing pyroute2.egg-info/PKG-INFO writing dependency_links to pyroute2.egg-info/dependency_links.txt writing requirements to pyroute2.egg-info/requires.txt writing top-level names to pyroute2.egg-info/top_level.txt reading manifest file 'pyroute2.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'python-pyroute2.spec' writing manifest file 'pyroute2.egg-info/SOURCES.txt' running build_ext Traceback (most recent call last): File "setup.py", line 89, in long_description=readme.read()) File "/usr/lib/python3.7/site-packages/setuptools/init.py", line 145, in setup return distutils.core.setup(**attrs) File "/usr/lib/python3.7/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/lib/python3.7/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/usr/lib/python3.7/site-packages/setuptools/command/test.py", line 229, in run self.run_tests() File "/usr/lib/python3.7/site-packages/setuptools/command/test.py", line 251, in run_tests exit=False, File "/usr/lib/python3.7/unittest/main.py", line 100, in init self.parseArgs(argv) File "/usr/lib/python3.7/unittest/main.py", line 124, in parseArgs self._do_discovery(argv[2:]) File "/usr/lib/python3.7/unittest/main.py", line 244, in _do_discovery self.createTests(from_discovery=True, Loader=Loader) File "/usr/lib/python3.7/unittest/main.py", line 154, in createTests self.test = loader.discover(self.start, self.pattern, self.top) File "/usr/lib/python3.7/unittest/loader.py", line 349, in discover tests = list(self._find_tests(start_dir, pattern)) File "/usr/lib/python3.7/unittest/loader.py", line 406, in _find_tests full_path, pattern, namespace) File "/usr/lib/python3.7/unittest/loader.py", line 483, in _find_test_path tests = self.loadTestsFromModule(package, pattern=pattern) File "/usr/lib/python3.7/site-packages/setuptools/command/test.py", line 55, in loadTestsFromModule tests.append(self.loadTestsFromName(submodule)) File "/usr/lib/python3.7/unittest/loader.py", line 191, in loadTestsFromName return self.loadTestsFromModule(obj) File "/usr/lib/python3.7/site-packages/setuptools/command/test.py", line 55, in loadTestsFromModule tests.append(self.loadTestsFromName(submodule)) File "/usr/lib/python3.7/unittest/loader.py", line 154, in loadTestsFromName module = import(module_name) File "/root/pkgs/pyroute2/pyroute2-0.5.17/pyroute2/remote/main.py", line 6, in Server(Transport(sys.stdin), Transport(sys.stdout)) File "/root/pkgs/pyroute2/pyroute2-0.5.17/pyroute2/remote/init.py", line 141, in Server 'error': None}) File "/root/pkgs/pyroute2/pyroute2-0.5.17/pyroute2/remote/init.py", line 49, in send self.file_obj.write(packet) TypeError: write() argument must be str, not bytes

Are the tests run in some different way? What if we want to run using setup.py? python Version=> Python 3.7.5

svinota commented 3 years ago

— The test documentation is not updated yet — The CI is in transition from nose to pytest — The tests require:

The full setup may be like that (depending on distribution, on Fedora it's dnf and a bit different package names:

# apt-get install postgresl-13 postgresql-server-dev-13  # or another version
# systemctl restart postgresql@13-main
# createdb pr2test
# make pytest  # installs deps via pip -- see also tests/requirements.txt

Or:

 # export SKIPDB=postgres
 # make pytest    # but psycopg2 is still required

So the nearest tasks are:

svinota commented 3 years ago

But wait:

# python setup.py test
running test
WARNING: Testing via this command is deprecated and will be removed in a future version.
Users looking for a generic test entry point independent of test runner are encouraged to use tox.

Now I'm not sure about the setuptools tests integration.

@prashant1221 would you consider tox integration instead?

prashant1221 commented 3 years ago

But wait:

# python setup.py test
running test
WARNING: Testing via this command is deprecated and will be removed in a future version.
Users looking for a generic test entry point independent of test runner are encouraged to use tox.

Now I'm not sure about the setuptools tests integration.

@prashant1221 would you consider tox integration instead?

Sure, tox would also be fine. Thanks for all the info.