Skip to content

Commit bdbddc8

Browse files
committed
Rewrote a test to provide on-disk files instead of StringIO files to argparse (it seems optparse could handle this, but argparse can't).
- Legacy-Id: 12713
1 parent ef1b404 commit bdbddc8

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

ietf/utils/management/commands/tests.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
import tempfile
3+
14
from django.core.management import call_command
25
from django.test import TestCase
36
from django.utils.six import StringIO
@@ -7,8 +10,7 @@
710
class CoverageChangeTestCase(TestCase):
811

912
def test_coverage_change(self):
10-
master = StringIO(
11-
"""{
13+
master_txt ="""{
1214
"5.12.0": {
1315
"code": {
1416
"coverage": 0.5921474057048117,
@@ -40,9 +42,8 @@ def test_coverage_change(self):
4042
},
4143
"version": "5.12.0"
4244
}
43-
""")
44-
latest = StringIO(
45-
"""{
45+
"""
46+
latest_txt = """{
4647
"latest": {
4748
"code": {
4849
"coverage": 0.5921474057048117,
@@ -74,11 +75,19 @@ def test_coverage_change(self):
7475
},
7576
"version":"latest"
7677
}
77-
""")
78+
"""
79+
mfh, master = tempfile.mkstemp(suffix='.json')
80+
with open(master, "w") as file:
81+
file.write(master_txt)
82+
lfh, latest = tempfile.mkstemp(suffix='.json')
83+
with open(latest, "w") as file:
84+
file.write(latest_txt)
7885
output = StringIO()
7986
call_command('coverage_changes', master, latest, stdout=output)
8087
text = output.getvalue()
81-
88+
os.unlink(master)
89+
os.unlink(latest)
90+
8291
for l in [
8392
r"admin/group/group/change_form.html False True",
8493
r"^api/v1/?$ True False",

0 commit comments

Comments
 (0)