unit-testing

Python 3.4 DeprecationWarning convert_charrefs

假如想象 提交于 2021-01-28 10:10:46
问题 Using UnitTest in the shell: python3.4 -m unittest my_test.py -v I get the DeprecationWarning DeprecationWarning: The value of convert_charrefs will become True in 3.5. You are encouraged to set the value explicitly. super().__init__() ERROR So it seems super().__init__() triggers this DeprecationWarning. But I can not find anything about convert_charrefs warning. Also the used statement is used in the Python documentation, and multiple examples in SO. What causes this warning, and how can I

JAVA - LocalDate.plusDay() doesn't work properly [duplicate]

社会主义新天地 提交于 2021-01-28 09:08:25
问题 This question already has answers here : Why LocalDate.plusDays not working here? (2 answers) Closed 2 years ago . I want to create method thatd add trainings which belongs to some trainingCycle to calendar. Problably I made some mistake becouse it's adding all trainings to only one day. TrainingCycle model class: @DynamoDBTable(tableName = "trainingCycle") public class TrainingCycle extends Request { private String id; private String cycleName; private Long cycleTime; private LocalDateTime

Stub any instance of a class in dart

微笑、不失礼 提交于 2021-01-28 09:01:03
问题 Developing with ruby on rails allowed to do things like : File.any_instance.expects(:delete) This was a great way to test for side effects within a method call. How to do the equivalent in dart? For example if you have in dart : class Storage { // the function to test void deleteFile(String path) { var fileToDelete = new File(path); if (await fileToDelete.exists()) { await fileToDelete.delete(); } } } ... test("#deleteFile delete the file exists", () { storage = new Storage(); // something

Mutation testing - Pittest error (No mutations found)

北城余情 提交于 2021-01-28 08:45:37
问题 I am using https://github.com/hcoles/pitest to write mutation tests on our existing Unit Test suite. We are getting an error as below: 12:09:40 PM PIT >> INFO : MINION : 12:09:40 PM PIT >> FINE : Expecting 1 tests classes from parent 12:09:40 PM PIT >> INFO : MINION : 12:09:40 PM PIT >> FINE : Tests classes received 12:09:40 PM PIT >> INFO : MINION : 12:09:40 PM PIT >> INFO : Found 0 tests 12:09:40 PM PIT >> INFO : MINION : 12:09:40 PM PIT >> INFO : Dependency analysis reduced number of

sinon stub for Lambda using promises

天涯浪子 提交于 2021-01-28 08:27:45
问题 I just started using sinon, and I had some initial success stubbing out DynamoDB calls: sandbox = sinon.createSandbox() update_stub = sandbox.stub(AWS.DynamoDB.DocumentClient.prototype, 'update').returns({ promise: () => Promise.resolve(update_meeting_result) }) This works great. But I also need to stub Lambda, and the same approach isn't working: lambda_stub = sandbox.stub(AWS.Lambda.prototype, 'invoke').returns({ promise: () => Promise.resolve({lambda_invoke_result}) // }) With this, I get

How can be any service injected into WebTestCase subclass in Symfony?

强颜欢笑 提交于 2021-01-28 08:26:04
问题 Maybe I am missing something... doh, I think so, but could not find an answer to that. WebTestCase generates this constructor sample: public function __construct(?string $name = null, array $data = [], string $dataName = '') { parent::__construct($name, $data, $dataName); } Was trying to add my service as the first or last argument - Symfony throws an error: Type error: Too few arguments to function Tests\AppBundle\Manager\ContactManagerTest::__construct(), 0 passed in /Library/WebServer

Is it possible to check condition coverage with gcov?

…衆ロ難τιáo~ 提交于 2021-01-28 08:22:16
问题 By condition coverage, I mean like in the definition here. I didn't find such option in the documentation here. An option that gives me relevant statistics which I can parse easily condition coverage is also fine - but I can't find one. 来源: https://stackoverflow.com/questions/48260434/is-it-possible-to-check-condition-coverage-with-gcov

Using mock to test if directory exists or not

坚强是说给别人听的谎言 提交于 2021-01-28 07:44:48
问题 I have been exploring mock and pytest for a few days now. I have the following method: def func(): if not os.path.isdir('/tmp/folder'): os.makedirs('/tmp/folder') In order to unit test it, I have decided to patch os.path.isdir and os.makedirs, as shown: @patch('os.path.isdir') @patch('os.makedirs') def test_func(patch_makedirs, patch_isdir): patch_isdir.return_value = False assert patch_makedirs.called == True The assertion fails, irrespective of the return value from patch_isdir. Can someone

How can I write tests that have setup and teardown operations that are asynchronous?

百般思念 提交于 2021-01-28 07:03:09
问题 I am using a library (pouchDB) that does some async operations. To keep things simple, I will keep the details out of it as I think this is a general issue with "unit testing" involving async operations (unit testing in quotation marks because I guess this isn't truly unit testing if I am testing integration with another library. But, using QUnit seems like the most appropriate way to write tests for it). I am using QUnit to do my js unit testing. I have two tests. I am finding that if I run

Run Jest test in IntelliJ IDEA

杀马特。学长 韩版系。学妹 提交于 2021-01-28 06:41:08
问题 I created a React app with create-react-app version 1.4.0 and opened the resulting project in IntelliJ. Now I am attempting to run the generated test in IntelliJ as well. I get the following output when I do so: /usr/bin/node /home/l/src/hello-react/node_modules/jest/bin/jest --config {\"rootDir\":\"/home/l/src/hello-react\",\"transformIgnorePatterns\":[\"/node_modules/\",\"^/home/l/bin/idea-IU-172.3544.35/plugins/JavaScriptLanguage/helpers\"],\"unmockedModulePathPatterns\":[\"^/home/l/bin