Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make `python setup.py test` work (in a fresh virtualenv!) for

buildbot/master
  • Loading branch information...
commit 18a64779cca54aedba6091ee40c2dda5a3ced70c 1 parent 5dffe8d
Marc Abramowitz msabramo authored

Showing 2 changed files with 8 additions and 103 deletions. Show diff stats Hide diff stats

  1. +2 0  master/setup.cfg
  2. +6 103 master/setup.py
2  master/setup.cfg
... ... @@ -0,0 +1,2 @@
  1 +[aliases]
  2 +test = trial -m buildbot
109 master/setup.py
@@ -37,107 +37,6 @@ def include(d, e):
37 37
38 38 return (d, [f for f in glob.glob('%s/%s'%(d, e)) if os.path.isfile(f)])
39 39
40   -class _SetupBuildCommand(Command):
41   - """
42   - Master setup build command to subclass from.
43   - """
44   -
45   - user_options = []
46   -
47   - def initialize_options(self):
48   - """
49   - Setup the current dir.
50   - """
51   - self._dir = os.getcwd()
52   -
53   - def finalize_options(self):
54   - """
55   - Required.
56   - """
57   - pass
58   -
59   -
60   -class TestCommand(_SetupBuildCommand):
61   - """
62   - Executes tests from setup.
63   - """
64   -
65   - description = "Run unittests inline"
66   -
67   - def run(self):
68   - """
69   - Public run method.
70   - """
71   - self._run(os.path.normpath(os.path.abspath(
72   - os.path.join('buildbot', 'test'))))
73   -
74   - def _run(self, test_loc):
75   - """
76   - Executes the test step.
77   -
78   - @param test_loc: location of test module
79   - @type test_loc: str
80   - """
81   - from twisted.scripts.trial import run
82   -
83   - # remove the 'test' option from argv
84   - sys.argv.remove('test')
85   -
86   - # Mimick the trial script by adding the path as the last arg
87   - sys.argv.append(test_loc)
88   -
89   - # Add the current dir to path and pull it all together
90   - sys.path.insert(0, os.path.curdir)
91   - sys.path[:] = map(os.path.abspath, sys.path)
92   - # GO!
93   - run()
94   -
95   -
96   -class SdistTestCommand(TestCommand):
97   - """
98   - Runs unittests from the sdist output.
99   - """
100   -
101   - description = "Run unittests from inside an sdist distribution"
102   -
103   - def run(self):
104   - """
105   - Interesting magic to get a source dist and running trial on it.
106   -
107   - NOTE: there is magic going on here! If you know a better way feel
108   - free to update it.
109   - """
110   - # Clean out dist/
111   - if os.path.exists('dist'):
112   - for root, dirs, files in os.walk('dist', topdown=False):
113   - for name in files:
114   - os.remove(os.path.join(root, name))
115   - for name in dirs:
116   - os.rmdir(os.path.join(root, name))
117   - # Import setup making it as if we ran setup.py with the sdist arg
118   - sys.argv.append('sdist')
119   - import setup #@Reimport @UnresolvedImport @UnusedImport
120   - try:
121   - # attempt to extract the sdist data
122   - from gzip import GzipFile
123   - from tarfile import TarFile
124   - # We open up the gzip as well as using the first item as the sdist
125   - gz = GzipFile(os.path.join('dist', os.listdir('dist')[0]))
126   - tf = TarFile(fileobj=gz)
127   - # Make the output dir and generate the extract path
128   - os.mkdir(os.path.join('dist', 'sdist_test'))
129   - ex_path = os.path.join('dist', 'sdist_test',
130   - tf.getmembers()[0].name, 'buildbot', 'test')
131   - # Extract the data and run tests
132   - print "Extracting to %s" % ex_path
133   - tf.extractall(os.path.join('dist', 'sdist_test'))
134   - print "Executing tests ..."
135   - self._run(os.path.normpath(os.path.abspath(ex_path)))
136   - except IndexError, ie:
137   - # We get called twice and the IndexError is OK
138   - pass
139   -
140   -
141 40 class install_data_twisted(install_data):
142 41 """make sure data files are installed in package.
143 42 this is evil.
@@ -265,8 +164,6 @@ def make_release_tree(self, base_dir, files):
265 164 ],
266 165 'scripts': scripts,
267 166 'cmdclass': {'install_data': install_data_twisted,
268   - 'test': TestCommand,
269   - 'sdist_test': SdistTestCommand,
270 167 'sdist': our_sdist},
271 168 }
272 169
@@ -295,6 +192,12 @@ def make_release_tree(self, base_dir, files):
295 192 'sqlalchemy-migrate ==0.6.1, ==0.7.0, ==0.7.1, ==0.7.2',
296 193 'python-dateutil==1.5',
297 194 ]
  195 + setup_args['setup_requires'] = [
  196 + 'setuptools_trial',
  197 + ]
  198 + setup_args['tests_require'] = [
  199 + 'mock',
  200 + ]
298 201 # Python-2.6 and up includes json
299 202 if not py_26:
300 203 setup_args['install_requires'].append('simplejson')

0 comments on commit 18a6477

Please sign in to comment.
Something went wrong with that request. Please try again.