11import os
2+ import shutil
23import tempfile
34
45from setuptools import sandbox
@@ -12,7 +13,6 @@ def test_asyncbleach():
1213 with open (os .path .join (tmpdir1 , "source.py" ), 'w' ) as f :
1314 f .write ("async def f(): return await 1 \n " )
1415
15-
1616 asyncbleach .bleach (
1717 os .path .join (tmpdir1 , "source.py" ), fromdir = tmpdir1 , todir = tmpdir2
1818 )
@@ -23,7 +23,21 @@ def test_asyncbleach():
2323 assert bleached_code == "def f(): return 1 \n "
2424
2525
26-
2726def test_bleach_build_py ():
28- path_to_setup_py = os .path .join (os .path .dirname (os .path .abspath (__file__ )), './example_pkg/setup.py' )
29- sandbox .run_setup (path_to_setup_py , ['build' ])
27+ with tempfile .TemporaryDirectory () as tmpdir :
28+ source_pkg_dir = os .path .join (
29+ os .path .dirname (os .path .abspath (__file__ )), 'example_pkg'
30+ )
31+ pkg_dir = os .path .join (tmpdir , 'example_pkg' )
32+ shutil .copytree (source_pkg_dir , pkg_dir )
33+
34+ pkg_dir = os .path .join (tmpdir , 'example_pkg' )
35+ path_to_setup_py = os .path .join (pkg_dir , 'setup.py' )
36+ sandbox .run_setup (path_to_setup_py , ['build' ])
37+
38+ bleached = os .path .join (
39+ pkg_dir , 'build/lib/example_pkg/_sync/__init__.py'
40+ )
41+ with open (bleached ) as f :
42+ bleached_code = f .read ()
43+ assert bleached_code == "def f():\n return 1\n "
0 commit comments