55import glob
66import os
77import sys
8- import unittest
98
109from distutils .core import Command
1110from setuptools import setup
@@ -28,114 +27,16 @@ def get_version():
2827
2928
3029class TestCommand (Command ):
31- user_options = [
32- ("ro-functional" , None ,
33- "Run readonly functional tests against actual bugzilla instances. "
34- "This will be very slow." ),
35- ("rw-functional" , None ,
36- "Run read/write functional tests against actual bugzilla instances. "
37- "As of now this only runs against partner-bugzilla.redhat.com, "
38- "which requires an RH bugzilla account with cached cookies. "
39- "This will also be very slow." ),
40- ("only=" , None ,
41- "Run only tests whose name contains the passed string" ),
42- ("redhat-url=" , None ,
43- "Redhat bugzilla URL to use for ro/rw_functional tests" ),
44- ("debug" , None ,
45- "Enable python-bugzilla debug output. This may break output "
46- "comparison tests." ),
47- ]
30+ user_options = []
4831
4932 def initialize_options (self ):
50- self .ro_functional = False
51- self .rw_functional = False
52- self .only = None
53- self .redhat_url = None
54- self .debug = False
55-
33+ pass
5634 def finalize_options (self ):
5735 pass
5836
5937 def run (self ):
60- os .environ ["__BUGZILLA_UNITTEST" ] = "1"
61-
62- try :
63- import coverage
64- usecov = int (coverage .__version__ .split ("." )[0 ]) >= 3
65- except :
66- usecov = False
67-
68- if usecov :
69- cov = coverage .coverage (omit = [
70- "/*/tests/*" , "/usr/*" , "*dev-env*" , "*.tox/*" ])
71- cov .erase ()
72- cov .start ()
73-
74- testfiles = []
75- for t in glob .glob (os .path .join (os .getcwd (), 'tests' , '*.py' )):
76- if t .endswith ("__init__.py" ):
77- continue
78-
79- base = os .path .basename (t )
80- if (base == "ro_functional.py" and not self .ro_functional ):
81- continue
82-
83- if (base == "rw_functional.py" and not self .rw_functional ):
84- continue
85-
86- testfiles .append ('.' .join (['tests' , os .path .splitext (base )[0 ]]))
87-
88-
89- if hasattr (unittest , "installHandler" ):
90- try :
91- unittest .installHandler ()
92- except :
93- print ("installHandler hack failed" )
94-
95- import tests as testsmodule
96- testsmodule .REDHAT_URL = self .redhat_url
97- if self .debug :
98- import logging
99- import bugzilla
100- logging .getLogger (bugzilla .__name__ ).setLevel (logging .DEBUG )
101- os .environ ["__BUGZILLA_UNITTEST_DEBUG" ] = "1"
102-
103- tests = unittest .TestLoader ().loadTestsFromNames (testfiles )
104- if self .only :
105- newtests = []
106- for suite1 in tests :
107- for suite2 in suite1 :
108- for testcase in suite2 :
109- if self .only in str (testcase ):
110- newtests .append (testcase )
111-
112- if not newtests :
113- print ("--only didn't find any tests" )
114- sys .exit (1 )
115-
116- tests = unittest .TestSuite (newtests )
117- print ("Running only:" )
118- for test in newtests :
119- print ("%s" % test )
120- print ()
121-
122-
123- verbosity = 1
124- if self .ro_functional or self .rw_functional :
125- verbosity = 2
126- t = unittest .TextTestRunner (verbosity = verbosity )
127-
128- result = t .run (tests )
129-
130- if usecov :
131- cov .stop ()
132- cov .save ()
133-
134- err = int (bool (len (result .failures ) > 0 or
135- len (result .errors ) > 0 ))
136- if not err and usecov :
137- cov .report (show_missing = False )
138- sys .exit (err )
38+ print ("\n * Tests are now run with the 'pytest' tool.\n "
39+ "* See CONTRIBUTING.md for details." )
13940
14041
14142class PylintCommand (Command ):
@@ -206,6 +107,7 @@ def _parse_requirements(fname):
206107 ret .append (line )
207108 return ret
208109
110+
209111setup (name = 'python-bugzilla' ,
210112 version = get_version (),
211113 description = 'Bugzilla XMLRPC access module' ,
0 commit comments