File: test_private.py

package info (click to toggle)
python-public 4.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 200 kB
  • sloc: python: 366; makefile: 11; sh: 3
file content (58 lines) | stat: -rw-r--r-- 923 bytes parent folder | download | duplicates (2)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from importlib import import_module

import pytest


def test_atprivate(example):
    example("""\
from public import private

@private
def a_function():
    pass
""")
    module = import_module('example')
    assert 'a_function' not in module.__all__


def test_atprivate_with_dunder_all(example):
    example("""\
from public import private

__all__ = ['a_function']

@private
def a_function():
    pass
""")
    module = import_module('example')
    assert 'a_function' not in module.__all__


def test_atprivate_adds_dunder_all(example):
    example("""\
from public import private

@private
def a_function():
    pass
""")
    module = import_module('example')
    assert module.__all__ == []


def test_all_is_a_tuple(example):
    example("""\
__all__ = ('foo',)

from public import private

def foo():
    pass

@private
def bar():
    pass
""")
    with pytest.raises(ValueError):
        import_module('example')