summaryrefslogtreecommitdiff
path: root/setuptools/tests/test_depends.py
blob: fcf2a636a4b687ba6fd364294cc6cffdce47e307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sys

from setuptools import depends


class TestGetModuleConstant:

	def test_basic(self):
		"""
		Invoke get_module_constant on a module in
		the test package.
		"""
		mod_name = 'setuptools.tests.mod_with_constant'
		val = depends.get_module_constant(mod_name, 'value')
		assert val == 'three, sir!'
		assert 'setuptools.tests.mod_with_constant' not in sys.modules


class TestIterCode:
	def test_empty(self):
		code = compile('', '<string>', mode='exec')
		expected = (100, 0), (83, None)
		assert tuple(depends._iter_code(code)) == expected

	def test_constant(self):
		code = compile('value = "three, sir!"', '<string>', mode='exec')
		expected = (100, 0), (90, 0), (100, 1), (83, None)
		assert tuple(depends._iter_code(code)) == expected