Sto provando l'editor di Atom e mi chiedevo come posso eseguire i test delle unità Python con una scorciatoia da tastiera.Come eseguire un test di unità Python con l'editor di Atom?
5
A
risposta
9
installazione
- Installare il Atom editor di
Installare il pacchetto Script in questo modo:
a) Avviare Atom
b) Premere Ctrl + Maiusc + P, digitare "installare i pacchetti e le tematiche" e premere Invio per aprire la vista del pacchetto
c) La ricerca di "script" e installare il pacchetto
Unità esempio test test .py
Scrivi una prova di unità e salvarlo come
test.py
.import unittest class MyTest(unittest.TestCase): def test_pass(self): pass def test_fail(self): call_method_that_does_not_exist() if __name__ == '__main__': unittest.main()
unit test Run
- Ora, premere Ctrl+I per eseguire lo script Python (see documentation)
uscita Console
Poiché il test di unità test_fail
fallirà, questo sarà l'output della console:
E.
======================================================================
ERROR: test_fail (__main__.MyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/Lernkurve/Desktop/PythonDemos/a.py", line 9, in test_fail
call_method_that_does_not_exist()
NameError: global name 'call_method_that_does_not_exist' is not defined
----------------------------------------------------------------------
Ran 2 tests in 0.000s
FAILED (errors=1)
[Finished in 0.047s]
1
è possibile utilizzare il plug-in Atom Python Test. Supporta:
- eseguire il test sotto il cursore
- eseguire tutti i test di un modulo
- test Run doc
supporta anche l'aggiunta di argomenti aggiuntivi per testare l'esecuzione e consente di eseguire unitttest. Anche TestCase.
Problemi correlati
- 1. Python CLI unità programma di test
- 2. Come posso eseguire python anaconda con atom 1.0
- 3. Copertura test unità Python
- 4. Test unità di base e test unità
- 5. Come saltare determinati test con Test :: Unità
- 6. python & maven (integrazione test unità)
- 7. Ottenere karma grunt per eseguire un test di unità
- 8. Come eseguire un programma in Atom Editor?
- 9. Unità regole di test
- 10. Unità test decoratori in Python
- 11. Esegui test di unità con Naso in un ambiente Python come Autodesk Maya?
- 12. Test di unità Android con proguard abilitato
- 13. Test delle unità di scrittura in Python: come si avvia?
- 14. Unità di test con una libreria statica
- 15. Come posso eseguire un programma Java nell'editor di Atom?
- 16. (unità) Test di ArrayAdapter
- 17. Test unità Visual Studio C# - Esegui test unità con inizializzazioni test multiple/multiple, Esegui stesso test unità più volte?
- 18. Come accedere automaticamente al feed atom di Gmail con Python?
- 19. Can Atom funziona con Python virtualenvwrapper
- 20. Come inviare le richieste con JSONs in unità di test
- 21. Interfacce di test unità con Moq
- 22. come unità di richiesta di test AFNetworking
- 23. installatori di test unità
- 24. Test di unità Python Perfom tramite un'interfaccia web
- 25. Impossibile eseguire i test delle unità WP81 con VSTest.Console.exe
- 26. Crea progetto Maven senza eseguire test di unità
- 27. "Test unità" un report
- 28. IList test di unità con CollectionAssert
- 29. Come posso eseguire il test continuo di unità/unità in Coffeescript?
- 30. Test di unità ASP.NET WebApi con Request.CreateResponse
Funziona alla grande! Lo uso con pytest, quindi ho aggiunto il codice per avviare l'esecuzione di test: 'if __name __ == '__main__': pytest.main ([__ file__, '--color = yes'])' – Jonatan