from __future__ import print_function, unicode_literals

import sys

import pytest


if __name__ == '__main__':
    sys.exit(pytest.main(sys.argv[1:]))

from __future__ import print_function, unicode_literals

import sys

import pytest


if __name__ == '__main__':
    if len(sys.argv) >= 2 and sys.argv[1] != '--':
        args = ['--db', sys.argv[1]] + sys.argv[2:]
    else:
        args = sys.argv[1:]

    sys.exit(pytest.main(args))

Fix running unit tests through the old test runner.
Fix running unit tests through the old test runner.

The old test runner (currently used in CI) had a regression when moving
to pytest. It failed to convert the first argument (the database name to
run everything against) to the new `pytest --db=` argument.

This change adds this back to the test runner. If an argument is passed,
and isn't `--`, it's expected to be the database name as before. All
other arguments are then passed as normal.

Testing Done:
Ran the old test runner with/without a database name, with/without `--`,
and with/without specific tests to run.

Reviewed at https://reviews.reviewboard.org/r/12129/

  from __future__ import print_function, unicode_literals
  
  import sys
  
  import pytest
  
  
  if __name__ == '__main__':
-     sys.exit(pytest.main(sys.argv[1:]))
+     if len(sys.argv) >= 2 and sys.argv[1] != '--':
+         args = ['--db', sys.argv[1]] + sys.argv[2:]
+     else:
+         args = sys.argv[1:]
  
+     sys.exit(pytest.main(args))
+ 
Fix running unit tests through the old test runner.
## Code Before:
from __future__ import print_function, unicode_literals

import sys

import pytest


if __name__ == '__main__':
    sys.exit(pytest.main(sys.argv[1:]))

## Instruction:
Fix running unit tests through the old test runner.
## Code After:
from __future__ import print_function, unicode_literals

import sys

import pytest


if __name__ == '__main__':
    if len(sys.argv) >= 2 and sys.argv[1] != '--':
        args = ['--db', sys.argv[1]] + sys.argv[2:]
    else:
        args = sys.argv[1:]

    sys.exit(pytest.main(args))
