Debian Codegraph @

tests/test_clean.py

raw
1 # SPDX-FileCopyrightText: 2021-present Ofek Lev <[email protected]>
2 #
3 # SPDX-License-Identifier: MIT
4 import os
5 import platform
6 import subprocess
7 import sys
8 from glob import glob
9
10 import pytest
11
12 from .utils import build_project
13
14 pytestmark = [pytest.mark.usefixtures('new_project')]
15
16
17 def test():
18 compiled_extension = '.pyd' if platform.system() == 'Windows' else '.so'
19 shared_lib_pattern = f'*__mypyc.*{compiled_extension}'
20 lib_pattern = f'my_app{os.path.sep}*.*{compiled_extension}'
21
22 assert not glob(shared_lib_pattern)
23 assert not glob(lib_pattern)
24
25 build_project()
26
27 assert len(glob(shared_lib_pattern)) == 1
28 assert len(glob(lib_pattern)) == 2
29
30 process = subprocess.run(
31 [sys.executable, '-m', 'hatchling', 'build', '-t', 'wheel', '--clean-only'],
32 stdout=subprocess.PIPE,
33 stderr=subprocess.STDOUT,
34 )
35 if process.returncode: # no cov
36 raise Exception(process.stdout.decode('utf-8'))
37
38 assert not glob(shared_lib_pattern)
39 assert not glob(lib_pattern)