#!/usr/bin/env python

import subprocess
import unittest


class TestPy2Py3Compat(unittest.TestCase):
    """We need to be compatible with both python2 and 3.

    Test that we can at least import runlint.py under both.
    """
    def test_python2_compat(self):
        subprocess.check_call(['python2', '-c',  'import runlint'])

    def test_python3_compat(self):
        subprocess.check_call(['python3', '-c',  'import runlint'])

Add a test that imports runlint under both python2 and python3
Add a test that imports runlint under both python2 and python3

Summary:
khan-linter now runs under both python2 and python3, but it's going to be easy
to break that.  This commit adds a test that checks that runlint.py can be
imported in both python2 and python3.  This won't catch everything, but will
prevent a few common issues, like print statements without parens and octal
literals for permissions.

Test Plan:
- `python -m unittest python_version_compat_test`
- verify it passes
- add a `print 'broken'` to runlint.py
- repeat, and verify the python3 test fails

Reviewers: csilvers

Reviewed By: csilvers

Subscribers: tom, kevinb

Differential Revision: https://phabricator.khanacademy.org/D35087
