summaryrefslogtreecommitdiff
path: root/_pytest
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2018-03-13 18:08:26 +0100
committerRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2018-03-13 18:13:56 +0100
commit87f200324506d09a819b66d3af06ac4c9777480f (patch)
tree52515ec069e3feb75fab57cc925e6197009e1da0 /_pytest
parentf8791c9246ce83544878ce563b20691b8b1870d7 (diff)
downloadpytest-87f200324506d09a819b66d3af06ac4c9777480f.tar.gz
remove CmdOptions since we can use argparse.Namespace()
Diffstat (limited to '_pytest')
-rw-r--r--_pytest/config.py24
1 files changed, 6 insertions, 18 deletions
diff --git a/_pytest/config.py b/_pytest/config.py
index cdd996896..63c7dc3bb 100644
--- a/_pytest/config.py
+++ b/_pytest/config.py
@@ -5,7 +5,7 @@ import shlex
import traceback
import types
import warnings
-
+import copy
import six
import py
# DON't import pytest here because it causes import cycle troubles
@@ -68,7 +68,7 @@ def main(args=None, plugins=None):
return 4
-class cmdline(object): # compatibility namespace
+class cmdline(object): # NOQA compatibility namespace
main = staticmethod(main)
@@ -845,19 +845,6 @@ def _ensure_removed_sysmodule(modname):
pass
-class CmdOptions(object):
- """ holds cmdline options as attributes."""
-
- def __init__(self, values=()):
- self.__dict__.update(values)
-
- def __repr__(self):
- return "<CmdOptions %r>" % (self.__dict__,)
-
- def copy(self):
- return CmdOptions(self.__dict__)
-
-
class Notset(object):
def __repr__(self):
return "<NOTSET>"
@@ -885,7 +872,7 @@ class Config(object):
def __init__(self, pluginmanager):
#: access to command line option as attributes.
#: (deprecated), use :py:func:`getoption() <_pytest.config.Config.getoption>` instead
- self.option = CmdOptions()
+ self.option = argparse.Namespace()
_a = FILE_OR_DIR
self._parser = Parser(
usage="%%(prog)s [options] [%s] [%s] [...]" % (_a, _a),
@@ -989,7 +976,7 @@ class Config(object):
self.pluginmanager._set_initial_conftests(early_config.known_args_namespace)
def _initini(self, args):
- ns, unknown_args = self._parser.parse_known_and_unknown_args(args, namespace=self.option.copy())
+ ns, unknown_args = self._parser.parse_known_and_unknown_args(args, namespace=copy.copy(self.option))
r = determine_setup(ns.inifilename, ns.file_or_dir + unknown_args, warnfunc=self.warn,
rootdir_cmd_arg=ns.rootdir or None)
self.rootdir, self.inifile, self.inicfg = r
@@ -1054,7 +1041,8 @@ class Config(object):
self.pluginmanager.consider_preparse(args)
self.pluginmanager.load_setuptools_entrypoints('pytest11')
self.pluginmanager.consider_env()
- self.known_args_namespace = ns = self._parser.parse_known_args(args, namespace=self.option.copy())
+ self.known_args_namespace = ns = self._parser.parse_known_args(
+ args, namespace=copy.copy(self.option))
if self.known_args_namespace.confcutdir is None and self.inifile:
confcutdir = py.path.local(self.inifile).dirname
self.known_args_namespace.confcutdir = confcutdir