mirror of https://github.com/yandex/gixy
Migrate test fixtures to pytest
parent
b57037bd82
commit
d9a3496de8
|
@ -5,15 +5,14 @@ from gixy.core.variable import Variable
|
|||
from gixy.core.regexp import Regexp
|
||||
|
||||
|
||||
def setup():
|
||||
def setup_function():
|
||||
assert len(CONTEXTS) == 0
|
||||
|
||||
|
||||
def tear_down():
|
||||
def teardown_function():
|
||||
purge_context()
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_push_pop_context():
|
||||
root_a = Root()
|
||||
push_context(root_a)
|
||||
|
@ -30,7 +29,6 @@ def test_push_pop_context():
|
|||
assert poped.block == root_a
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_push_get_purge_context():
|
||||
root = Root()
|
||||
push_context(root)
|
||||
|
@ -45,7 +43,6 @@ def test_push_get_purge_context():
|
|||
assert len(CONTEXTS) == 0
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_add_variables():
|
||||
context = push_context(Root())
|
||||
assert len(context.variables['index']) == 0
|
||||
|
@ -68,7 +65,6 @@ def test_add_variables():
|
|||
assert context.variables['name']['some'] == some_var
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_get_variables():
|
||||
context = push_context(Root())
|
||||
assert len(context.variables['index']) == 0
|
||||
|
@ -91,7 +87,6 @@ def test_get_variables():
|
|||
assert context.get_var('args')
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_context_depend_variables():
|
||||
push_context(Root())
|
||||
assert len(get_context().variables['index']) == 0
|
||||
|
@ -124,7 +119,6 @@ def test_context_depend_variables():
|
|||
assert get_context().get_var(1).value == 'one'
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_push_failed_with_regexp_py35_gixy_10():
|
||||
push_context(Root())
|
||||
assert len(get_context().variables['index']) == 0
|
||||
|
|
|
@ -4,15 +4,14 @@ from gixy.directives.block import Root
|
|||
from gixy.core.regexp import Regexp
|
||||
from gixy.core.variable import Variable
|
||||
|
||||
def setup():
|
||||
def setup_function():
|
||||
push_context(Root())
|
||||
|
||||
|
||||
def tear_down():
|
||||
def teardown_function():
|
||||
purge_context()
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_literal():
|
||||
var = Variable(name='simple', value='$uri', have_script=False)
|
||||
assert not var.depends
|
||||
|
@ -28,7 +27,6 @@ def test_literal():
|
|||
assert not var.must_startswith('u')
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_regexp():
|
||||
var = Variable(name='simple', value=Regexp('^/.*'))
|
||||
assert not var.depends
|
||||
|
@ -44,7 +42,6 @@ def test_regexp():
|
|||
assert not var.must_startswith('a')
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_script():
|
||||
get_context().add_var('foo', Variable(name='foo', value=Regexp('.*')))
|
||||
var = Variable(name='simple', value='/$foo')
|
||||
|
@ -62,7 +59,6 @@ def test_script():
|
|||
assert not var.must_startswith('a')
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_regexp_boundary():
|
||||
var = Variable(name='simple', value=Regexp('.*'), boundary=Regexp('/[a-z]', strict=True))
|
||||
assert not var.depends
|
||||
|
@ -80,7 +76,6 @@ def test_regexp_boundary():
|
|||
assert not var.must_startswith('a')
|
||||
|
||||
|
||||
@with_setup(setup, tear_down)
|
||||
def test_script_boundary():
|
||||
get_context().add_var('foo', Variable(name='foo', value=Regexp('.*'), boundary=Regexp('[a-z]', strict=True)))
|
||||
var = Variable(name='simple', value='/$foo', boundary=Regexp('[/a-z0-9]', strict=True))
|
||||
|
|
Loading…
Reference in New Issue