Skip to content

Commit c3c8218

Browse files
committed
tests/conftest.py: tox: Remove root dir from sys.path
When using tox, it can accidentally pick up a {pymssql,_mssql}.so file in the root directory and then get ImportError because of incompatibility in Python versions. By removing the root directory from the sys.path, it forces tox to import the library from correct place in the tox virtualenv.
1 parent f1d7ec5 commit c3c8218

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/conftest.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
from os.path import dirname
2+
import sys
3+
4+
# When using tox, it can accidentally pick up a {pymssql,_mssql}.so file in the
5+
# root directory and then get ImportError because of incompatibility in Python
6+
# versions. By removing the root directory from the sys.path, it forces tox to
7+
# import the library from correct place in the tox virtualenv.
8+
if '.tox' in sys.executable:
9+
root_dir = dirname(dirname(__file__))
10+
sys.path.remove(root_dir)
11+
112
import decimal
213
import os
314
try:

0 commit comments

Comments
 (0)