mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Add a tool to make an empty unittest script
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Name: etgtools/make-new-etg-file.py
|
||||
# Name: bin/make-new-etg-file.py
|
||||
# Author: Kevin Ollivier
|
||||
#
|
||||
# Created: 24-Sept-2011
|
||||
@@ -73,6 +72,8 @@ if __name__ == '__main__':
|
||||
|
||||
"""
|
||||
|
||||
# TODO: refactor to just use make-new-unittest-file instead of duplicating it here...
|
||||
|
||||
unitteststub = """\
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
|
||||
64
bin/make-new-unittest-file.py
Executable file
64
bin/make-new-unittest-file.py
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python
|
||||
#---------------------------------------------------------------------------
|
||||
# Name: bin/make-new-unittest-file.py
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 12-July-2012
|
||||
# Copyright: (c) 2012 by Robin Dunn
|
||||
# License: wxWindows License
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
root_dir = os.path.abspath(os.path.join(script_dir, ".."))
|
||||
|
||||
usage = "usage: %prog [options] name module"
|
||||
unitteststub = """\
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class %(name)s_Tests(wtc.WidgetTestCase):
|
||||
|
||||
# TODO: Remove this test and add real ones.
|
||||
def test_%(name)s1(self):
|
||||
self.fail("Unit tests for %(name)s not implemented yet.")
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
def main(args):
|
||||
if not args:
|
||||
print("usage: %s names" % __file__)
|
||||
return
|
||||
|
||||
for name in args:
|
||||
writeFile(
|
||||
os.path.join(root_dir, "unittests", "test_%s.py" % name),
|
||||
unitteststub, dict(name=name))
|
||||
|
||||
|
||||
def writeFile(filename, stub, values):
|
||||
if os.path.exists(filename):
|
||||
print("'%s' already exists. Exiting." % filename)
|
||||
sys.exit(1)
|
||||
output = open(filename, 'w')
|
||||
output.write(stub % values)
|
||||
output.close()
|
||||
print("Wrote %s" % filename)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1:])
|
||||
Reference in New Issue
Block a user