unittest gives error
See original GitHub issueHi there, and thanks for a great tool.
I was trying to use unittest (which is part of the PSL) with the following program:
import unittest
def sort_i(unsortedArray,direction="ASC"):
sortedArray = [];
for i in unsortedArray[1:]:
print i
return sortedArray
class TestSortInsertion(unittest.TestCase):
def test_base(self):
self.assertEqual(sort_i([1,3,4,2]), [1,2,3,4])
if __name__ == '__main__':
unittest.main()
But I get the following error:
Fprocessing.app.SketchException: AttributeError: FakeStdErr instance has no attribute 'flush'
at jycessing.mode.run.SketchRunner.convertPythonSketchError(SketchRunner.java:240)
at jycessing.mode.run.SketchRunner.access$4(SketchRunner.java:227)
at jycessing.mode.run.SketchRunner$3.run(SketchRunner.java:122)
at java.lang.Thread.run(Thread.java:748)
Any idea?
thanks a lot
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
unittest — Unit testing framework — Python 3.11.1 ...
Unittest supports skipping individual test methods and even whole classes of tests. In addition, it supports marking a test as an “expected failure,”...
Read more >Python unittest: make AssertionError an error instead of a failure
failureException : This class attribute gives the exception raised by the test method. If a test framework needs to use a specialized exception, ......
Read more >Test if a function throws an exception in Python - GeeksforGeeks
The test passes if exception is raised, gives an error if another exception is raised, or fails if no exception is raised.
Read more >How to catch a raise error in python unittest - YouTube
When you developer your code and want to test somthing there crash you code so its not react wirdt you mabey use raise...
Read more >Fix Installation Error of 'unittest' - Finxter
The following video shows you how to resolve the ImportError : How to Fix : “ImportError: Cannot import name X” in Python?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you so much – for the patch, and for the workaround, which I can confirm is working for me.
I have put together a related demo sketch for Processing.py users who want to use
unittest
(not as main) in a normal sketch, e.g. from setup() or on keyPressed(). I haven’t really begun using it myself, so feedback most welcome.https://github.com/jeremydouglass/processingpy_unittest
Good suggestion – I bundled it into a collection repo called processingpy_import_examples and linked to it on the forum.