Register pytest marks to remove warnings

This commit is contained in:
Ordanis Sanchez
2020-05-10 15:26:15 -04:00
parent 78ad294092
commit 1c447e21c6
2 changed files with 4 additions and 18 deletions
+4
View File
@@ -0,0 +1,4 @@
[pytest]
markers =
render: marks tests for html render
internet: marks tests which runs on internet pages
-18
View File
@@ -30,20 +30,17 @@ def async_get(event_loop):
return partial(async_session.get, url) return partial(async_session.get, url)
@pytest.mark.ok
def test_file_get(): def test_file_get():
r = get() r = get()
assert r.status_code == 200 assert r.status_code == 200
@pytest.mark.ok
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_async_file_get(async_get): async def test_async_file_get(async_get):
r = await async_get() r = await async_get()
assert r.status_code == 200 assert r.status_code == 200
@pytest.mark.ok
def test_class_seperation(): def test_class_seperation():
r = get() r = get()
@@ -51,7 +48,6 @@ def test_class_seperation():
assert len(about.attrs['class']) == 2 assert len(about.attrs['class']) == 2
@pytest.mark.ok
def test_css_selector(): def test_css_selector():
r = get() r = get()
@@ -65,7 +61,6 @@ def test_css_selector():
assert menu_item in about.full_text.split('\n') assert menu_item in about.full_text.split('\n')
@pytest.mark.ok
def test_containing(): def test_containing():
r = get() r = get()
@@ -76,7 +71,6 @@ def test_containing():
assert 'python' in e.full_text.lower() assert 'python' in e.full_text.lower()
@pytest.mark.ok
def test_attrs(): def test_attrs():
r = get() r = get()
about = r.html.find('#about', first=True) about = r.html.find('#about', first=True)
@@ -85,7 +79,6 @@ def test_attrs():
assert len(about.attrs['class']) == 2 assert len(about.attrs['class']) == 2
@pytest.mark.ok
def test_links(): def test_links():
r = get() r = get()
about = r.html.find('#about', first=True) about = r.html.find('#about', first=True)
@@ -94,7 +87,6 @@ def test_links():
assert len(about.absolute_links) == 6 assert len(about.absolute_links) == 6
@pytest.mark.ok
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_async_links(async_get): async def test_async_links(async_get):
r = await async_get() r = await async_get()
@@ -104,14 +96,12 @@ async def test_async_links(async_get):
assert len(about.absolute_links) == 6 assert len(about.absolute_links) == 6
@pytest.mark.ok
def test_search(): def test_search():
r = get() r = get()
style = r.html.search('Python is a {} language')[0] style = r.html.search('Python is a {} language')[0]
assert style == 'programming' assert style == 'programming'
@pytest.mark.ok
def test_xpath(): def test_xpath():
r = get() r = get()
html = r.html.xpath('/html', first=True) html = r.html.xpath('/html', first=True)
@@ -121,7 +111,6 @@ def test_xpath():
assert '#site-map' in a_hrefs assert '#site-map' in a_hrefs
@pytest.mark.ok
def test_html_loading(): def test_html_loading():
doc = """<a href='https://httpbin.org'>""" doc = """<a href='https://httpbin.org'>"""
html = HTML(html=doc) html = HTML(html=doc)
@@ -131,7 +120,6 @@ def test_html_loading():
assert isinstance(html.html, str) assert isinstance(html.html, str)
@pytest.mark.ok
def test_anchor_links(): def test_anchor_links():
r = get() r = get()
r.html.skip_anchors = False r.html.skip_anchors = False
@@ -139,7 +127,6 @@ def test_anchor_links():
assert '#site-map' in r.html.links assert '#site-map' in r.html.links
@pytest.mark.ok
@pytest.mark.parametrize('url,link,expected', [ @pytest.mark.parametrize('url,link,expected', [
('http://example.com/', 'test.html', 'http://example.com/test.html'), ('http://example.com/', 'test.html', 'http://example.com/test.html'),
('http://example.com', 'test.html', 'http://example.com/test.html'), ('http://example.com', 'test.html', 'http://example.com/test.html'),
@@ -164,7 +151,6 @@ def test_absolute_links(url, link, expected):
assert html.absolute_links.pop() == expected assert html.absolute_links.pop() == expected
@pytest.mark.parser
def test_parser(): def test_parser():
doc = """<a href='https://httpbin.org'>httpbin.org\n</a>""" doc = """<a href='https://httpbin.org'>httpbin.org\n</a>"""
html = HTML(html=doc) html = HTML(html=doc)
@@ -303,7 +289,6 @@ async def test_bare_js_async_eval():
await html.browser.close() await html.browser.close()
@pytest.mark.ok
def test_browser_session(): def test_browser_session():
""" Test browser instaces is created and properly close when session is closed. """ Test browser instaces is created and properly close when session is closed.
Note: session.close method need to be tested together with browser creation, Note: session.close method need to be tested together with browser creation,
@@ -315,7 +300,6 @@ def test_browser_session():
# assert count_chromium_process() == 0 # assert count_chromium_process() == 0
@pytest.mark.ok
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_browser_session_fail(): async def test_browser_session_fail():
""" HTMLSession.browser should not be call within an existing event loop> """ """ HTMLSession.browser should not be call within an existing event loop> """
@@ -324,7 +308,6 @@ async def test_browser_session_fail():
session.browser session.browser
@pytest.mark.ok
def test_browser_process(): def test_browser_process():
for _ in range(3): for _ in range(3):
r = get() r = get()
@@ -333,7 +316,6 @@ def test_browser_process():
assert r.html.page == None assert r.html.page == None
@pytest.mark.ok
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_async_browser_session(): async def test_async_browser_session():
session = AsyncHTMLSession() session = AsyncHTMLSession()