SickGear/tests/compatibility_tests.py
Adam 37496189f1 Change py2 exception clauses to py2/3 compatible clauses
Add py2/3 regression testing for exception clauses

Any new code added with old py2 style exceptions will now fail the travis test
2015-06-08 22:56:45 +08:00

28 lines
No EOL
1 KiB
Python

import unittest
import subprocess
import os
class CompatibilityTests(unittest.TestCase):
def test_except(self):
path = os.path.abspath('..')
pyfiles = []
for rootdir in ['sickbeard', 'tests']:
for dirpath, subdirs, files in os.walk(os.path.join(path, rootdir)):
for x in files:
if x.endswith('.py'):
pyfiles.append(os.path.join(dirpath, x))
pyfiles.append(os.path.join(path,'SickBeard.py'))
output = subprocess.Popen('2to3 -f except %s' % ' '.join(pyfiles), shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0]
if output:
print('Changes to be made for Python 2/3 compatibility as follows:')
print(output)
self.fail('Python 2/3 incompatibility detected')
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(QualityTests)
unittest.TextTestRunner(verbosity=2).run(suite)