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
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
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
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