Skip to content

Commit 7afa066

Browse files
committed
Fix how tests find compiled libraries
The tests add the build directory to the path so we can test without installing. Unfortunately this is currently a manual search for the library as I'm not sure how to get it directly from distutils. In the past the search was limited to build directories for the current version, such as "2.7" or "3.9". This commit adds the system to it to differentiate between 32-bit and 64-bit builds on Windows.
1 parent bcf9063 commit 7afa066

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests2/testutils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os, sys, platform
44
from os.path import join, dirname, abspath, basename
55
import unittest
6+
from distutils.util import get_platform
67

78
def add_to_path():
89
"""
@@ -20,7 +21,7 @@ def add_to_path():
2021

2122
# Only go into directories that match our version number.
2223

23-
dir_suffix = '-%s.%s' % (sys.version_info[0], sys.version_info[1])
24+
dir_suffix = '%s-%s.%s' % (get_platform(), sys.version_info[0], sys.version_info[1])
2425

2526
build = join(dirname(dirname(abspath(__file__))), 'build')
2627

@@ -32,6 +33,7 @@ def add_to_path():
3233
for name in library_names:
3334
if name in files:
3435
sys.path.insert(0, root)
36+
print('Library:', join(root, name))
3537
return
3638

3739
print('Did not find the pyodbc library in the build directory. Will use an installed version.')

tests3/testutils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os, sys, platform
22
from os.path import join, dirname, abspath, basename
33
import unittest
4+
from distutils.util import get_platform
45

56
def add_to_path():
67
"""
@@ -18,7 +19,7 @@ def add_to_path():
1819

1920
# Only go into directories that match our version number.
2021

21-
dir_suffix = '-%s.%s' % (sys.version_info[0], sys.version_info[1])
22+
dir_suffix = '%s-%s.%s' % (get_platform(), sys.version_info[0], sys.version_info[1])
2223

2324
build = join(dirname(dirname(abspath(__file__))), 'build')
2425

@@ -30,6 +31,7 @@ def add_to_path():
3031
for name in library_names:
3132
if name in files:
3233
sys.path.insert(0, root)
34+
print('Library:', join(root, name))
3335
return
3436

3537
print('Did not find the pyodbc library in the build directory. Will use an installed version.')

0 commit comments

Comments
 (0)