~jayvdb/testscenarios/fix-py3-tests

« back to all changes in this revision

Viewing changes to README

  • Committer: John Vandenberg
  • Date: 2015-04-26 04:56:30 UTC
  • Revision ID: jayvdb@gmail.com-20150426045630-jwx4450r9e5ensq0
Fix tests to support Python 3 use of <locals> in names

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
``testscenarios.generate_scenarios()``. For instance::
99
99
 
100
100
  >>> import unittest
101
 
  >>> import StringIO
 
101
  >>> try:
 
102
  ...     from StringIO import StringIO
 
103
  ... except ImportError:
 
104
  ...     from io import StringIO
102
105
  >>> from testscenarios.scenarios import generate_scenarios
103
106
 
104
107
This can work with loaders and runners from the standard library, or possibly other
106
109
 
107
110
  >>> loader = unittest.TestLoader()
108
111
  >>> test_suite = unittest.TestSuite()
109
 
  >>> runner = unittest.TextTestRunner(stream=StringIO.StringIO())
 
112
  >>> runner = unittest.TextTestRunner(stream=StringIO())
110
113
 
111
114
  >>> mytests = loader.loadTestsFromNames(['doc.test_sample'])
112
115
  >>> test_suite.addTests(generate_scenarios(mytests))
211
214
  ...
212
215
  >>> suite2 = unittest.TestSuite()
213
216
  >>> suite2.addTests(generate_scenarios(suite))
214
 
  >>> print suite2.countTestCases()
 
217
  >>> print(suite2.countTestCases())
215
218
  4
216
219
 
217
220
Dynamic Scenarios