15
0
forked from pool/python-aenum
Files
python-aenum/tempdir_missing.patch

106 lines
3.6 KiB
Diff
Raw Normal View History

---
aenum/test.py | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
Index: aenum-3.1.5/aenum/test.py
===================================================================
--- aenum-3.1.5.orig/aenum/test.py
+++ aenum-3.1.5/aenum/test.py
@@ -49,13 +49,18 @@ def load_tests(loader, tests, ignore):
return tests
class TestCase(unittest.TestCase):
-
def __init__(self, *args, **kwds):
regex = getattr(self, 'assertRaisesRegex', None)
if regex is None:
self.assertRaisesRegex = getattr(self, 'assertRaisesRegexp')
super(TestCase, self).__init__(*args, **kwds)
+ def setUp(self):
+ self.tempdir = tempfile.mkdtemp()
+ if pyver >= (3, ):
+ test_v3.tempdir = self.tempdir
+ # self.addCleanup(shutil.rmtree, self.tempdir, True)
+
# for pickle tests
try:
@@ -943,6 +948,8 @@ class TestEnum(TestCase):
IDES_OF_MARCH = 2013, 3, 15
self.Holiday = Holiday
+ super(TestEnum, self).setUp()
+
def test_set_name(self):
class Descriptor(object):
name = None
@@ -2051,7 +2058,7 @@ class TestEnum(TestCase):
# for use with both Python 2/3
JSONEnum = JSONEnumMeta('JsonEnum', (Enum, ), {})
- test_file = os.path.join(tempdir, 'test_json.json')
+ test_file = os.path.join(self.tempdir, 'test_json.json')
with open(test_file, 'w') as f:
f.write(
'[{"name":"Afghanistan","alpha-2":"AF","country-code":"004","notes":{"description":"pretty"}},'
@@ -4002,6 +4009,8 @@ class TestFlag(TestCase):
CE = 1<<19
self.Open = Open
+ super(TestFlag, self).setUp()
+
def test_set_name(self):
class Descriptor(object):
name = None
@@ -4264,7 +4273,7 @@ class TestFlag(TestCase):
self.assertEqual(AS.STREET._value_, 32)
self.assertEqual(AS.SECONDARY_TYPE._value_, 128)
self.assertEqual((AS.NAME | AS.STREET)._value_, 48, "%r is not 48" % (AS.NAME | AS.STREET))
-
+
def test_iteration(self):
C = self.Color
self.assertEqual(list(C), [C.RED, C.GREEN, C.BLUE])
@@ -4957,6 +4966,8 @@ class TestIntFlag(TestCase):
self.Color = Color
self.Open = Open
+ super(TestIntFlag, self).setUp()
+
def test_set_name(self):
class Descriptor(object):
name = None
@@ -6127,10 +6138,10 @@ class TestStackoverflowAnswers(TestCase)
fh.write('#define %s %r\n' % (enum.name, enum.value))
class Arduino(CHeader):
_order_ = 'ONE TWO'
- __header = os.path.join(tempdir, 'arduino.h')
+ __header = os.path.join(self.tempdir, 'arduino.h')
ONE = 1
TWO = 2
- with open(os.path.join(tempdir, 'arduino.h')) as fh:
+ with open(os.path.join(self.tempdir, 'arduino.h')) as fh:
data = fh.read()
self.assertEqual(textwrap.dedent("""\
initial header stuff here
@@ -6595,18 +6606,3 @@ class TestIntEnumConvert(TestCase):
if name[0:2] not in ('CO', '__')],
[], msg='Names other than CONVERT_TEST_* found.')
-
-
-if __name__ == '__main__':
- tempdir = tempfile.mkdtemp()
- try:
- if PY3:
- test_v3.tempdir = tempdir
- test = unittest.main(exit=False)
- sys.stdout.flush()
- for name, reason in test.result.skipped:
- print("%s: %s" % (name, reason))
- finally:
- shutil.rmtree(tempdir, True)
- sys.exit(len(test.result.errors or test.result.failures) and 1 or 0)
-