def _test_active_custom_class(): assert not active('/hello/', class_='other-class') assert active(ACTIVE_PATH, class_='other-class') == 'other-class' assert active('/hello/', ACTIVE_PATH[:5], partial=True, class_='other-class') == 'other-class' assert active('/hello/', ACTIVE_PATH, class_='other-class') == 'other-class' assert not active('/hello/', '/world/', class_='other-class')
def _test_active_backward_compatibilty(): assert active([ '/hello/', ACTIVE_PATH, ]) == 'active' assert not active([ '/hello/', '/world/', ]) assert active([ ACTIVE_PATH[:5], ], partial=True) == 'active'
def test_active_index(c): with c.app.test_request_context('/index.html', method='GET'): assert active('/') == 'active' assert active('/index.html') == 'active' assert active('') == 'active' with c.app.test_request_context('/foo/bar/index.html', method='GET'): assert active('/foo/bar') == 'active' assert active('/foo/bar/') == 'active' assert active('/foo/bar/index.html') == 'active' with c.app.test_request_context('/', method='GET'): assert active('/') == 'active' assert active('/index.html') == 'active' assert active('') == 'active'
def _test_active(): assert not active('/hello/') assert active(ACTIVE_PATH) == 'active' assert active('/hello/', ACTIVE_PATH[:5], partial=True) == 'active' assert active('/hello/', ACTIVE_PATH) == 'active' assert not active('/hello/', '/world/')
def _test_active_backward_compatibilty(): assert active(['/hello/', ACTIVE_PATH, ]) == 'active' assert not active(['/hello/', '/world/', ]) assert active([ACTIVE_PATH[:5], ], partial=True) == 'active'
def _test_active_patterns(): assert active('/*/bar.html') == 'active' assert active('/fo?/bar.html') == 'active' assert active('/f*') == 'active'
def _test_active_relative(): assert not active('meh') assert active('bar.html') == 'active' assert active('b', partial=True) == 'active'
def _test_active_case(path, as_expected, partial=False): html = active(path, partial=partial) assert (html == 'active') is as_expected