Merge commit '79278364898eccc08d6bbe6e956b6774bb332c24' into template-tests
# Conflicts: # CI.md # test/02_test/test/spam_test.py # test/10_cpp_standards/cibuildwheel_test.py
This commit is contained in:
@@ -15,13 +15,52 @@ project_with_a_test = CTemplateProject(
|
||||
)
|
||||
|
||||
project_with_a_test.files['test/spam_test.py'] = r'''
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import struct
|
||||
from unittest import TestCase
|
||||
|
||||
import spam
|
||||
|
||||
|
||||
def path_contains(parent, child):
|
||||
""" returns True if `child` is inside `parent`.
|
||||
Works around path-comparison bugs caused by short-paths on Windows e.g.
|
||||
vssadm~1 instead of vssadministrator
|
||||
"""
|
||||
parent = os.path.abspath(parent)
|
||||
child = os.path.abspath(child)
|
||||
|
||||
while child != os.path.dirname(child):
|
||||
child = os.path.dirname(child)
|
||||
if os.stat(parent) == os.stat(child):
|
||||
# parent and child refer to the same directory on the filesystem
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class TestSpam(TestCase):
|
||||
def test_system(self):
|
||||
self.assertEqual(0, spam.system('python -c "exit(0)"'))
|
||||
self.assertNotEqual(0, spam.system('python -c "exit(1)"'))
|
||||
|
||||
def test_virtualenv(self):
|
||||
virtualenv_path = os.environ.get("__CIBW_VIRTUALENV_PATH__")
|
||||
if not virtualenv_path:
|
||||
self.fail("No virtualenv path defined in environment variable __CIBW_VIRTUALENV_PATH__")
|
||||
|
||||
self.assertTrue(path_contains(virtualenv_path, sys.executable))
|
||||
self.assertTrue(path_contains(virtualenv_path, spam.__file__))
|
||||
|
||||
def test_uname(self):
|
||||
if platform.system() == "Windows":
|
||||
return
|
||||
# if we're running in 32-bit Python, check that the machine is i686.
|
||||
# See #336 for more info.
|
||||
bits = struct.calcsize("P") * 8
|
||||
if bits == 32:
|
||||
self.assertEqual(platform.machine(), "i686")
|
||||
'''
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user