OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Using setUp defined variables in parametrized.expand

  • Thread starter Thread starter Dylan Galea
  • Start date Start date
D

Dylan Galea

Guest
Suppose that I have the following unit test class:

Code:
class Test(unittest.TestCase)
    def setUp(self) -> None:
        self.test_parameter1 = 'A'
        self.test_parameter2 = 'B'
    
    @parametrized.expand([('A',), ('B',)])
    def test_function1(self, test_param):
        * Do tests here *

Is there a way how can I use self.test_parameter1 and self.test_parameter2 in parameterized.expand instead of the literals A and B? Imagine A and B are large dicts, the tests would be very messy in this case if two large dicts are given to parametrized_expand.
<p>Suppose that I have the following unit test class:</p>
<pre><code>class Test(unittest.TestCase)
def setUp(self) -> None:
self.test_parameter1 = 'A'
self.test_parameter2 = 'B'

@parametrized.expand([('A',), ('B',)])
def test_function1(self, test_param):
* Do tests here *
</code></pre>
<p>Is there a way how can I use <code>self.test_parameter1</code> and <code>self.test_parameter2</code> in <code>parameterized.expand</code> instead of the literals <code>A</code> and <code>B</code>? Imagine <code>A</code> and <code>B</code> are large dicts, the tests would be very messy in this case if two large dicts are given to <code>parametrized_expand</code>.</p>
 

Latest posts

Top