问题
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
来源:https://stackoverflow.com/questions/57449887/is-there-a-possibility-to-pass-start-arguments-to-setup-py-test