1

I have a problem with the CI of my python project, the project is a python API which communicates with a server. To make it possible, to run builds concurrently I must have a possibility to pass the servers port to the python setup.py test command. For example python setup.py test --port 1337. Is there any possibility to get this done?

At the moment I have a setup.py file and use unittest for testing, but I'm totally free to use another framework like nose. The important thing is to pass the port while trigger the tests over the setup.py file!

EDIT: With nosetest I have the problem that I'm not able to pass a custom command. If my setup.cfg looks like this:

[nosetests]
with-xunit=1

I can call the tests with the command python setup.py nostests --with-xunit without problems. But if I try to add a custom parameter like the port:

[nosetests]
port=1

and try to execute I can call the tests with the command python setup.py nostests --port=1337 I get the following error error: option --port not recognized What can I do to get this work?

EDIT2: I've get it done by using argpaser. Here is a simple example setup.py file which shows how it works:

import argparse
import sys

argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument('--port', help='required port argument', required=True)
args, unknown = argparser.parse_known_args()
sys.argv = [sys.argv[0]] + unknown
print(args)



from setuptools import setup


setup(
    version='1.0',
    description='example',
    author='example',
    author_email='example@example.net',
)

This can be executed with python setup.py test --port 1337

Sloug
  • 11
  • 3
  • https://stackoverflow.com/a/39874096/7976758 – phd Aug 11 '19 at 12:36
  • Or you can override `test` command. Something like this: https://stackoverflow.com/a/20248942/7976758 – phd Aug 11 '19 at 12:37
  • Ok thank you very much, I've decided to use your second answer, because I was not able to get it done with nose. This approach works now, but I'm still interested in other, maybe better solutions for this problem. – Sloug Aug 11 '19 at 14:33

0 Answers0