| 1 |
# SPDX-FileCopyrightText: 2021-present Ofek Lev <[email protected]> |
| 2 |
# |
| 3 |
# SPDX-License-Identifier: MIT |
| 4 |
from hatch_mypyc.utils import construct_setup_file |
| 5 |
|
| 6 |
|
| 7 |
class TestConstructSetupFile: |
| 8 |
def test_no_arguments(self): |
| 9 |
assert ( |
| 10 |
construct_setup_file([], opt_level='3') |
| 11 |
== """\ |
| 12 |
from setuptools import setup |
| 13 |
from mypyc.build import mypycify |
| 14 |
|
| 15 |
setup( |
| 16 |
name='mypyc_output', |
| 17 |
ext_modules=mypycify( |
| 18 |
[ |
| 19 |
], |
| 20 |
opt_level='3', |
| 21 |
), |
| 22 |
) |
| 23 |
""" |
| 24 |
) |
| 25 |
|
| 26 |
def test_one_argument(self): |
| 27 |
assert ( |
| 28 |
construct_setup_file([], 'foo', opt_level='3') |
| 29 |
== """\ |
| 30 |
from setuptools import setup |
| 31 |
from mypyc.build import mypycify |
| 32 |
|
| 33 |
setup( |
| 34 |
name='mypyc_output', |
| 35 |
ext_modules=mypycify( |
| 36 |
[ |
| 37 |
'foo', |
| 38 |
], |
| 39 |
opt_level='3', |
| 40 |
), |
| 41 |
) |
| 42 |
""" |
| 43 |
) |
| 44 |
|
| 45 |
def test_multiple_arguments(self): |
| 46 |
assert ( |
| 47 |
construct_setup_file([], 'foo', 'bar', opt_level='3') |
| 48 |
== """\ |
| 49 |
from setuptools import setup |
| 50 |
from mypyc.build import mypycify |
| 51 |
|
| 52 |
setup( |
| 53 |
name='mypyc_output', |
| 54 |
ext_modules=mypycify( |
| 55 |
[ |
| 56 |
'foo', |
| 57 |
'bar', |
| 58 |
], |
| 59 |
opt_level='3', |
| 60 |
), |
| 61 |
) |
| 62 |
""" |
| 63 |
) |
| 64 |
|
| 65 |
def test_no_options(self): |
| 66 |
assert ( |
| 67 |
construct_setup_file([], 'foo', 'bar') |
| 68 |
== """\ |
| 69 |
from setuptools import setup |
| 70 |
from mypyc.build import mypycify |
| 71 |
|
| 72 |
setup( |
| 73 |
name='mypyc_output', |
| 74 |
ext_modules=mypycify( |
| 75 |
[ |
| 76 |
'foo', |
| 77 |
'bar', |
| 78 |
], |
| 79 |
), |
| 80 |
) |
| 81 |
""" |
| 82 |
) |
| 83 |
|
| 84 |
def test_packages_root(self): |
| 85 |
assert ( |
| 86 |
construct_setup_file('', 'foo') |
| 87 |
== """\ |
| 88 |
from setuptools import setup |
| 89 |
from mypyc.build import mypycify |
| 90 |
|
| 91 |
setup( |
| 92 |
name='mypyc_output', |
| 93 |
ext_modules=mypycify( |
| 94 |
[ |
| 95 |
'foo', |
| 96 |
], |
| 97 |
), |
| 98 |
) |
| 99 |
""" |
| 100 |
) |
| 101 |
|
| 102 |
def test_packages_source(self): |
| 103 |
assert ( |
| 104 |
construct_setup_file('src', 'foo') |
| 105 |
== """\ |
| 106 |
from setuptools import setup |
| 107 |
from mypyc.build import mypycify |
| 108 |
|
| 109 |
setup( |
| 110 |
name='mypyc_output', |
| 111 |
ext_modules=mypycify( |
| 112 |
[ |
| 113 |
'foo', |
| 114 |
], |
| 115 |
), |
| 116 |
package_dir={'': 'src'}, |
| 117 |
) |
| 118 |
""" |
| 119 |
) |