scientifichackers / ampy

MicroPython Tool - Utility to interact with a MicroPython board over a serial connection.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ampy test fails on windows.

youngsu999 opened this issue · comments

Test filas on windows 10 test_run_without_output test function

$ python test_files.py
..file-0
file-1
.file-0
file-1
file-2
.file-0
file-1
file-2
..........E
======================================================================
ERROR: test_run_without_output (__main__.TestFiles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_files.py", line 166, in test_run_without_output
    output = board_files.run(program.name, wait_output=False)
  File "C:\Users\youngsu\Anaconda3\lib\site-packages\adafruit_ampy-1.0.8.dev0+g2f7148f.d20181216-py3.6.egg\ampy\files.py", line 310, in run
    with open(filename, "rb") as infile:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\youngsu\\AppData\\Local\\Temp\\tmpso7llnh4'

----------------------------------------------------------------------
Ran 15 tests in 0.017s

FAILED (errors=1)

I found some related article and modified the test code.

    def test_run_without_output(self):
->      import os
        pyboard = mock.Mock()
        pyboard.exec_raw_no_follow = mock.Mock()
        board_files = files.Files(pyboard)
->      with tempfile.NamedTemporaryFile(delete=False) as program:
            program.write(b'print("Hello world")')
            program.flush()
            output = board_files.run(program.name, wait_output=False)
        self.assertEqual(output, None)
        pyboard.exec_raw_no_follow.assert_called_once_with(b'print("Hello world")')
->      os.remove(program.name)

Should we fix the tests for Windows on main branch?

Hiya! We are discontinuing support for ampy, and will no longer be maintaining it. We are leaving this repository available for continued use. If you would like to take over supporting it, please contact us on the Adafruit Discord server and we can transfer the repository to you.
If you wish to continue developing it on your own, please fork the repository.