File: test_optional.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 (38 lines) | stat: -rw-r--r-- 849 bytes parent folder | download | duplicates (4)
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
"""Test optional selectors."""
from .. import util


class TestOptional(util.TestCase):
    """Test optional selectors."""

    MARKUP = """
    <form>
    <input id="1" type="name" required>
    <input id="2" type="checkbox" required>
    <input id="3" type="email">
    <textarea id="4" name="name" cols="30" rows="10"></textarea>
    <select id="5" name="nm">
        <!-- options -->
    </select>
    </form>
    """

    def test_optional(self):
        """Test optional."""

        self.assert_selector(
            self.MARKUP,
            ":optional",
            ['3', '4', '5'],
            flags=util.HTML
        )

    def test_specific_optional(self):
        """Test specific optional."""

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