testing

How to run tests in a class sequentially in ScalaTest?

橙三吉。 提交于 2021-02-07 02:59:51
问题 I have a class which extends org.scalatest.junit.JUnitSuite. This class has a couple of tests. I do not want these tests to run in parallel. I know how simple it is with Specs2 (extend the class with Specification and add a single line sequential inside the class) as shown here: How to run specifications sequentially. I do not want to alter the Build file by setting: parallelExecution in Test := false nor I want to use tags to run specific test files sequentially. All I want is a way to make

How to test django model method __str__()

一世执手 提交于 2021-02-06 16:06:04
问题 I trying to test __str__ method, and when trying to access it in my test it returns my model instance (I think it is) def test_str_is_equal_to_title(self): """ Method `__str__` should be equal to field `title` """ work = Work.objects.get(pk=1) self.assertEqual(work.__str__, work.title) And from test I get: AssertionError: '<bound method Work.__str__ of <Work: Test title>>' != 'Test title' How I should compare these 2 values to pass test? 回答1: According to the documentation: Model.__str__()

How to test django model method __str__()

醉酒当歌 提交于 2021-02-06 16:05:02
问题 I trying to test __str__ method, and when trying to access it in my test it returns my model instance (I think it is) def test_str_is_equal_to_title(self): """ Method `__str__` should be equal to field `title` """ work = Work.objects.get(pk=1) self.assertEqual(work.__str__, work.title) And from test I get: AssertionError: '<bound method Work.__str__ of <Work: Test title>>' != 'Test title' How I should compare these 2 values to pass test? 回答1: According to the documentation: Model.__str__()

How to test django model method __str__()

假装没事ソ 提交于 2021-02-06 16:04:31
问题 I trying to test __str__ method, and when trying to access it in my test it returns my model instance (I think it is) def test_str_is_equal_to_title(self): """ Method `__str__` should be equal to field `title` """ work = Work.objects.get(pk=1) self.assertEqual(work.__str__, work.title) And from test I get: AssertionError: '<bound method Work.__str__ of <Work: Test title>>' != 'Test title' How I should compare these 2 values to pass test? 回答1: According to the documentation: Model.__str__()

selenium change language browser chrome / firefox

前提是你 提交于 2021-02-06 11:53:50
问题 I'm trying to test my website with selenium but I don't manage to change the language of the browser. I tried with firefox, changing the profile also but it's not working. That's a pity because many of my content is changing regarding the language. Here is my python code : @classmethod def setUpClass(cls): super(SeleniumTestCase, cls).setUpClass() options = Options() options.add_argument('--lang=en') cls.selenium = WebDriver(chrome_options=options) So normally I change the language but

selenium change language browser chrome / firefox

随声附和 提交于 2021-02-06 11:52:36
问题 I'm trying to test my website with selenium but I don't manage to change the language of the browser. I tried with firefox, changing the profile also but it's not working. That's a pity because many of my content is changing regarding the language. Here is my python code : @classmethod def setUpClass(cls): super(SeleniumTestCase, cls).setUpClass() options = Options() options.add_argument('--lang=en') cls.selenium = WebDriver(chrome_options=options) So normally I change the language but

selenium change language browser chrome / firefox

孤街醉人 提交于 2021-02-06 11:52:24
问题 I'm trying to test my website with selenium but I don't manage to change the language of the browser. I tried with firefox, changing the profile also but it's not working. That's a pity because many of my content is changing regarding the language. Here is my python code : @classmethod def setUpClass(cls): super(SeleniumTestCase, cls).setUpClass() options = Options() options.add_argument('--lang=en') cls.selenium = WebDriver(chrome_options=options) So normally I change the language but

selenium change language browser chrome / firefox

北城以北 提交于 2021-02-06 11:52:14
问题 I'm trying to test my website with selenium but I don't manage to change the language of the browser. I tried with firefox, changing the profile also but it's not working. That's a pity because many of my content is changing regarding the language. Here is my python code : @classmethod def setUpClass(cls): super(SeleniumTestCase, cls).setUpClass() options = Options() options.add_argument('--lang=en') cls.selenium = WebDriver(chrome_options=options) So normally I change the language but

Python Testing - Reset all mocks?

青春壹個敷衍的年華 提交于 2021-02-06 11:27:33
问题 When doing unit-testing with Python / PyTest, if you do you not have patch decorators or with patch blocks throughout your code, is there a way to reset all mocks at the end of every file / module to avoid inter-file test pollution? It seems like something that is mocked in one Python test file remains mocked in other file with the same return value, which means my mocks are persisting between tests and files (when a patch decorator or with patch block is NOT used). Is there any way around

Python Testing - Reset all mocks?

北战南征 提交于 2021-02-06 11:26:46
问题 When doing unit-testing with Python / PyTest, if you do you not have patch decorators or with patch blocks throughout your code, is there a way to reset all mocks at the end of every file / module to avoid inter-file test pollution? It seems like something that is mocked in one Python test file remains mocked in other file with the same return value, which means my mocks are persisting between tests and files (when a patch decorator or with patch block is NOT used). Is there any way around