File: test_lexer.py

package info (click to toggle)
python-lesscpy 0.15.1-0.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,488 kB
  • sloc: python: 3,591; sh: 5; makefile: 4
file content (46 lines) | stat: -rw-r--r-- 945 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
39
40
41
42
43
44
45
46
"""
Unit tests for the lexer.
"""
from tempfile import NamedTemporaryFile
import unittest

from six import StringIO

from lesscpy.lessc.lexer import LessLexer


class TestLessLexer(unittest.TestCase):
    """
    Unit tests for LessLexer
    """

    def setUp(self):
        self.lexer = LessLexer()

    def test_input_stream(self):
        """
        It can load content from a string.
        """
        file = StringIO("""
            @simple-var: 1;
            """)

        self.lexer.input(file)

        token = self.lexer.token()
        self.assertEqual('@simple-var', token.value)

    def test_input_path(self):
        """
        It can load content from a path.
        """
        file = NamedTemporaryFile()
        file.write(b"""
            @simple-var: 1;
            """)
        file.seek(0)

        self.lexer.input(file.name)

        token = self.lexer.token()
        self.assertEqual('@simple-var', token.value)