The python3 -m nose
command that we used earlier was not hard to understand, but it's longer than we'd like if we're going to be typing it all the time. Instead of the following command:
python3 -m nose --with-doctest --doctest-extension=txt -v
We'd really prefer just the following command:
python3 -m nose
or, even more simply:
nosetests
Fortunately, it's simple to tell Nose that we want it to use different defaults for the values of these command-line switches. To do this, just create a configuration file called nose.cfg
or .noserc
(either name will work) in your home directory, and place the following inside it:
[nosetests] with-doctest=1 doctest-extension=txtIf you're a Windows user, you might not be sure what the phrase "home directory" is supposed to denote in this context. As far as Python is concerned, your home directory is defined by your environment variables. If HOME is defined, that's your home directory. Otherwise, if USERPROFILE is defined (it usually is, pointing at C:Documents and SettingsUSERNAME) then that is considered to be your home directory. Otherwise, the directory described by HOMEDRIVE and HOMEPATH (often C:)is your home directory.
Setting the options in the configuration file takes care of all the extraneous command-line arguments. From now on, whenever you run Nose, it will assume these options, unless you tell it otherwise. You don't have to type them on the command line any more. You can use the same trick for any option that Nose can accept on the command line.
For the second refinement, Nose installs a script called nosetests
when it's installed. Typing nosetests
is exactly the same as typing python3 -m nose
, except that you might have to add the directory that contains nosetests
to your PATH
environment variable before it will work. We'll continue using python3 -m nose
in the examples.
3.144.255.87