aboutsummaryrefslogtreecommitdiff
path: root/tests/html
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2022-11-25 22:50:05 +0000
committerMichael Williamson <mike@zwobble.org>2022-11-25 22:58:16 +0000
commit5093d72b9fece1a7c3d7a3d19e4161387ee6475a (patch)
treec4122b0f72c7864897d78333e75328ac8c22685b /tests/html
parent20e3e61530bef546058124c3015ae240733cc974 (diff)
Use pytest instead of nose
Diffstat (limited to 'tests/html')
-rw-r--r--tests/html/collapse_tests.py40
-rw-r--r--tests/html/strip_empty_tests.py29
2 files changed, 25 insertions, 44 deletions
diff --git a/tests/html/collapse_tests.py b/tests/html/collapse_tests.py
index 5dc7e6c..ebffd69 100644
--- a/tests/html/collapse_tests.py
+++ b/tests/html/collapse_tests.py
@@ -1,62 +1,55 @@
-from nose.tools import istest, assert_equal
-
from mammoth import html
+from ..testing import assert_equal
-@istest
-def collapsing_does_nothing_to_single_text_node():
+def test_collapsing_does_nothing_to_single_text_node():
assert_equal(
html.collapse([html.text("Bluebells")]),
[html.text("Bluebells")])
-@istest
-def consecutive_fresh_elements_are_not_collapsed():
+def test_consecutive_fresh_elements_are_not_collapsed():
assert_equal(
html.collapse([html.element("p"), html.element("p")]),
[html.element("p"), html.element("p")])
-@istest
-def consecutive_collapsible_elements_are_collapsed_if_they_have_the_same_tag_and_attributes():
+def test_consecutive_collapsible_elements_are_collapsed_if_they_have_the_same_tag_and_attributes():
assert_equal(
[html.collapsible_element("p", {}, [html.text("One"), html.text("Two")])],
html.collapse([
html.collapsible_element("p", {}, [html.text("One")]),
html.collapsible_element("p", {}, [html.text("Two")])
]))
-
-@istest
-def elements_with_different_tag_names_are_not_collapsed():
+
+def test_elements_with_different_tag_names_are_not_collapsed():
assert_equal(
[
html.collapsible_element("p", {}, [html.text("One")]),
html.collapsible_element("div", {}, [html.text("Two")])
],
-
+
html.collapse([
html.collapsible_element("p", {}, [html.text("One")]),
html.collapsible_element("div", {}, [html.text("Two")])
]))
-
-@istest
-def elements_with_different_attributes_are_not_collapsed():
+
+def test_elements_with_different_attributes_are_not_collapsed():
assert_equal(
[
html.collapsible_element("p", {"id": "a"}, [html.text("One")]),
html.collapsible_element("p", {}, [html.text("Two")])
],
-
+
html.collapse([
html.collapsible_element("p", {"id": "a"}, [html.text("One")]),
html.collapsible_element("p", {}, [html.text("Two")])
]))
-@istest
-def children_of_collapsed_element_can_collapse_with_children_of_previous_element():
+def test_children_of_collapsed_element_can_collapse_with_children_of_previous_element():
assert_equal(
[
html.collapsible_element("blockquote", {}, [
@@ -66,7 +59,7 @@ def children_of_collapsed_element_can_collapse_with_children_of_previous_element
])
]),
],
-
+
html.collapse([
html.collapsible_element("blockquote", {}, [
html.collapsible_element("p", {}, [html.text("One")])
@@ -77,8 +70,7 @@ def children_of_collapsed_element_can_collapse_with_children_of_previous_element
]))
-@istest
-def collapsible_element_can_collapse_into_previous_fresh_element():
+def test_collapsible_element_can_collapse_into_previous_fresh_element():
assert_equal(
[html.element("p", {}, [html.text("One"), html.text("Two")])],
html.collapse([
@@ -87,8 +79,7 @@ def collapsible_element_can_collapse_into_previous_fresh_element():
]))
-@istest
-def element_with_choice_of_tag_names_can_collapse_into_previous_element_if_it_has_one_of_those_tag_names_as_its_main_tag_name():
+def test_element_with_choice_of_tag_names_can_collapse_into_previous_element_if_it_has_one_of_those_tag_names_as_its_main_tag_name():
assert_equal(
[html.collapsible_element(["ol"])],
html.collapse([
@@ -107,8 +98,7 @@ def element_with_choice_of_tag_names_can_collapse_into_previous_element_if_it_ha
]))
-@istest
-def when_separator_is_present_then_separator_is_prepended_to_collapsed_element():
+def test_when_separator_is_present_then_separator_is_prepended_to_collapsed_element():
assert_equal(
[
html.element("pre", collapsible=False, children=[
diff --git a/tests/html/strip_empty_tests.py b/tests/html/strip_empty_tests.py
index b72b50a..8660cff 100644
--- a/tests/html/strip_empty_tests.py
+++ b/tests/html/strip_empty_tests.py
@@ -1,65 +1,56 @@
-from nose.tools import istest, assert_equal
-
from mammoth import html
+from ..testing import assert_equal
-@istest
-def text_nodes_with_text_are_not_stripped():
+def test_text_nodes_with_text_are_not_stripped():
assert_equal(
[html.text("H")],
html.strip_empty([html.text("H")]))
-@istest
-def empty_text_nodes_are_stripped():
+def test_empty_text_nodes_are_stripped():
assert_equal(
[],
html.strip_empty([html.text("")]))
-@istest
-def elements_with_non_empty_children_are_not_stripped():
+def test_elements_with_non_empty_children_are_not_stripped():
assert_equal(
[html.element("p", {}, [html.text("H")])],
html.strip_empty([html.element("p", {}, [html.text("H")])]))
-@istest
-def elements_with_no_children_are_stripped():
+def test_elements_with_no_children_are_stripped():
assert_equal(
[],
html.strip_empty([html.element("p")]))
-@istest
-def elements_with_only_empty_children_are_stripped():
+def test_elements_with_only_empty_children_are_stripped():
assert_equal(
[],
html.strip_empty([html.element("p", {}, [html.text("")])]))
-@istest
-def empty_children_are_removed():
+def test_empty_children_are_removed():
assert_equal(
html.strip_empty([html.element("ul", {}, [
html.element("li", {}, [html.text("")]),
html.element("li", {}, [html.text("H")]),
])]),
-
+
[html.element("ul", {}, [
html.element("li", {}, [html.text("H")])
])])
-@istest
-def self_closing_elements_are_never_empty():
+def test_self_closing_elements_are_never_empty():
assert_equal(
[html.element("br")],
html.strip_empty([html.element("br")]))
-@istest
-def force_writes_are_never_empty():
+def test_force_writes_are_never_empty():
assert_equal(
[html.force_write],
html.strip_empty([html.force_write]))