def test_TypeValidator_invalid_region_no_list(): """Test that the validator raises for invalid sources with a region and no list""" testsrc = redbaron.RedBaron("def foo():\n\ta=1") validator = reddel_server.TypeValidator(['def']) with pytest.raises(reddel_server.ValidationException): validator(testsrc, start=reddel_server.Position(2, 3), end=reddel_server.Position(2, 4))
def test_TypeValidator_invalid_no_region_list(): """Test that the validator raises for invalid sources without a region but a list""" testsrc = redbaron.RedBaron("def foo(): pass\na=1") validator = reddel_server.TypeValidator(['def']) with pytest.raises(reddel_server.ValidationException): validator(testsrc)
def test_TypeValidator_valid_region_list(): """Test a valid source that is a list with a region""" testsrc = redbaron.RedBaron("a=1\ndef foo(): pass\ndef bar(): pass") validator = reddel_server.TypeValidator(['def']) validator(testsrc, start=reddel_server.Position(2, 1), end=reddel_server.Position(3, 1))
def test_TypeValidator_valid_region_no_list(): """Test a valid source where the region specifies a single node""" testsrc = redbaron.RedBaron("a=1\ndef foo(): pass\nb=2") validator = reddel_server.TypeValidator(['def']) validator(testsrc, start=reddel_server.Position(2, 1), end=reddel_server.Position(2, 1))
def test_TypeValidator_valid_no_region_list(): """Test a valid source that is a list without a region""" testsrc = redbaron.RedBaron("def foo(): pass\ndef bar(): pass") validator = reddel_server.TypeValidator(['def']) validator(testsrc)