Exemple #1
0
    def test_dofile_no_file(self):
        """If no file, dofile should fail."""

        s = MockSerial([b"",
                        # Check existance
                        b"=file.list()['test.lua']\r\n",
                        b"=file.list()['test.lua']\r\nnil\r\n"])
        n = NodeMCU(s)

        with pytest.raises(IOError):
            n.dofile("test.lua")

        assert s.finished
Exemple #2
0
    def test_dofile_no_file(self):
        """If no file, dofile should fail."""

        s = MockSerial([
            b"",
            # Check existance
            b"=file.list()['test.lua']\r\n",
            b"=file.list()['test.lua']\r\nnil\r\n"
        ])
        n = NodeMCU(s)

        with pytest.raises(IOError):
            n.dofile("test.lua")

        assert s.finished
Exemple #3
0
    def test_dofile(self):
        """Dofile should return command's output."""

        s = MockSerial([b"",
                        # Check existance
                        b"=file.list()['test.lua']\r\n",
                        b"=file.list()['test.lua']\r\n123\r\n",
                        # Execute and await prompt
                        b"dofile('test.lua')\r\n",
                        b"dofile('test.lua')\r\nhello!\r\n> "])
        n = NodeMCU(s)

        assert n.dofile("test.lua") == b"hello!\r\n"

        assert s.finished
Exemple #4
0
    def test_dofile(self):
        """Dofile should return command's output."""

        s = MockSerial([
            b"",
            # Check existance
            b"=file.list()['test.lua']\r\n",
            b"=file.list()['test.lua']\r\n123\r\n",
            # Execute and await prompt
            b"dofile('test.lua')\r\n",
            b"dofile('test.lua')\r\nhello!\r\n> "
        ])
        n = NodeMCU(s)

        assert n.dofile("test.lua") == b"hello!\r\n"

        assert s.finished