| --- smartypants.py-2.0.1/tests/test_cli.py.orig 2017-12-20 09:34:50.000000000 -0500 |
| +++ smartypants.py-2.0.1/tests/test_cli.py 2020-03-14 12:59:44.490259000 -0400 |
| @@ -7,6 +7,8 @@ |
| import tempfile |
| import unittest |
| from subprocess import PIPE, Popen |
| +if os.name == 'nt': |
| + import time |
| |
| CLI_SCRIPT = './smartypants' |
| |
| @@ -33,7 +35,10 @@ |
| T = '"foobar"' |
| E = '“foobar”' |
| |
| - output = self._p([CLI_SCRIPT], T) |
| + if os.name == 'nt': |
| + output = self._p(['python', CLI_SCRIPT], T) |
| + else: |
| + output = self._p([CLI_SCRIPT], T) |
| self.assertEquals(output, E) |
| |
| def test_pipe_attr(self): |
| @@ -41,11 +46,17 @@ |
| T = """"foo" ``bar''""" |
| |
| E = T |
| - output = self._p([CLI_SCRIPT, '--attr', '0'], T) |
| + if os.name == 'nt': |
| + output = self._p(['python', CLI_SCRIPT], T) |
| + else: |
| + output = self._p([CLI_SCRIPT, '--attr', '0'], T) |
| self.assertEquals(output, E) |
| |
| E = """"foo" “bar”""" |
| - output = self._p([CLI_SCRIPT, '--attr', 'b'], T) |
| + if os.name == 'nt': |
| + output = self._p(['python', CLI_SCRIPT, '--attr', 'b'], T) |
| + else: |
| + output = self._p([CLI_SCRIPT, '--attr', 'b'], T) |
| self.assertEquals(output, E) |
| |
| def test_skipped_elements(self): |
| @@ -53,19 +64,31 @@ |
| T = '<a>"foo"</a> <b>"bar"</b>' |
| |
| E = '<a>“foo”</a> <b>“bar”</b>' |
| - output = self._p([CLI_SCRIPT], T) |
| + if os.name == 'nt': |
| + output = self._p(['python', CLI_SCRIPT], T) |
| + else: |
| + output = self._p([CLI_SCRIPT], T) |
| self.assertEquals(output, E) |
| |
| E = '<a>"foo"</a> <b>“bar”</b>' |
| - output = self._p([CLI_SCRIPT, '--skip', 'a'], T) |
| + if os.name == 'nt': |
| + output = self._p(['python', CLI_SCRIPT, '--skip', 'a'], T) |
| + else: |
| + output = self._p([CLI_SCRIPT, '--skip', 'a'], T) |
| self.assertEquals(output, E) |
| |
| E = '<a>“foo”</a> <b>"bar"</b>' |
| - output = self._p([CLI_SCRIPT, '--skip', 'b'], T) |
| + if os.name == 'nt': |
| + output = self._p(['python', CLI_SCRIPT, '--skip', 'b'], T) |
| + else: |
| + output = self._p([CLI_SCRIPT, '--skip', 'b'], T) |
| self.assertEquals(output, E) |
| |
| E = T |
| - output = self._p([CLI_SCRIPT, '--skip', 'a,b'], T) |
| + if os.name == 'nt': |
| + output = self._p(['python', CLI_SCRIPT, '--skip', 'a,b'], T) |
| + else: |
| + output = self._p([CLI_SCRIPT, '--skip', 'a,b'], T) |
| self.assertEquals(output, E) |
| |
| def test_file(self): |
| @@ -78,7 +101,20 @@ |
| with open(F, 'w') as f: |
| f.write(T) |
| |
| - output = self._p([CLI_SCRIPT, F]) |
| + f.close() |
| + if os.name == 'nt': |
| + output = self._p(['python', CLI_SCRIPT, F]) |
| + else: |
| + output = self._p([CLI_SCRIPT, F]) |
| finally: |
| - os.remove(F) |
| + if os.name == 'nt': |
| + for i in range(3): |
| + try: |
| + os.remove(F) |
| + except WindowsError: |
| + time.sleep(0.1) |
| + else: |
| + break |
| + else: |
| + os.remove(F) |
| self.assertEquals(output, E) |