File: test_open.py

package info (click to toggle)
soupsieve 2.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,048 kB
  • sloc: python: 8,428; sh: 8; makefile: 5; javascript: 2
file content (76 lines) | stat: -rw-r--r-- 1,484 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Test open selectors."""
from .. import util


class TestOpen(util.TestCase):
    """Test open selectors."""

    MARKUP = """
    <!DOCTYPE html>
    <html>
    <body>

    <details id="1">
    <summary>This is closed.</summary<
    <p>A closed details element.</p>
    </details>

    <details id="2" open>
    <summary>This is open.</summary<
    <p>An open details element.</p>
    </details>

    <dialog id="3" open>
      <p>Greetings, one and all!</p>
      <form method="dialog">
        <button>OK</button>
      </form>
    </dialog>

    <dialog id="4">
      <p>Goodbye, one and all!</p>
      <form method="dialog">
        <button>OK</button>
      </form>
    </dialog>

    </body>
    </html>
    """

    def test_open(self):
        """Test open."""

        self.assert_selector(
            self.MARKUP,
            ":open",
            ['2', '3'],
            flags=util.HTML
        )

    def test_targted_open(self):
        """Test targeted open."""

        self.assert_selector(
            self.MARKUP,
            "details:open",
            ['2'],
            flags=util.HTML
        )

        self.assert_selector(
            self.MARKUP,
            "dialog:open",
            ['3'],
            flags=util.HTML
        )

    def test_not_open(self):
        """Test not open."""

        self.assert_selector(
            self.MARKUP,
            ":is(dialog, details):not(:open)",
            ["1", "4"],
            flags=util.HTML
        )