11import re
2- import pytest
2+
33import numpy as np
44import pandas as pd
5+ import pytest
56
67from dbldatagen import TextGenerator , TemplateGenerator
78
@@ -12,10 +13,14 @@ class TestTextGeneratorBasic:
1213 row_count = 100000
1314 partitions_requested = 4
1415
16+ class TestTextGenerator (TextGenerator ):
17+ def pandasGenerateText (self , v ): # pylint: disable=useless-parent-delegation
18+ return super ().pandasGenerateText (v )
19+
1520 @pytest .mark .parametrize ("randomSeed" , [None , 0 , - 1 , 2112 , 42 ])
1621 def test_text_generator_basic (self , randomSeed ):
17- text_gen1 = TextGenerator ()
18- text_gen2 = TextGenerator ()
22+ text_gen1 = self . TestTextGenerator ()
23+ text_gen2 = self . TestTextGenerator ()
1924
2025 if randomSeed is not None :
2126 text_gen1 = text_gen1 .withRandomSeed (randomSeed )
@@ -29,14 +34,19 @@ def test_text_generator_basic(self, randomSeed):
2934
3035 assert text_gen1 == text_gen2
3136
37+ def test_base_textgenerator_raises_error (self ):
38+ with pytest .raises (NotImplementedError ):
39+ text_gen1 = self .TestTextGenerator ()
40+ text_gen1 .pandasGenerateText (None )
41+
3242 @pytest .mark .parametrize ("randomSeed, forceNewInstance" , [(None , True ), (None , False ),
3343 (0 , True ), (0 , False ),
3444 (- 1 , True ), (- 1 , False ),
3545 (2112 , True ), (2112 , False ),
3646 (42 , True ), (42 , False )])
3747 def test_text_generator_rng (self , randomSeed , forceNewInstance ):
38- text_gen1 = TextGenerator ()
39- text_gen2 = TextGenerator ()
48+ text_gen1 = self . TestTextGenerator ()
49+ text_gen2 = self . TestTextGenerator ()
4050
4151 if randomSeed is not None :
4252 text_gen1 = text_gen1 .withRandomSeed (randomSeed )
@@ -71,7 +81,7 @@ def test_text_generator_rng(self, randomSeed, forceNewInstance):
7181 (np .array ([1 , 40000.4 , 3 ]), np .uint16 )
7282 ])
7383 def test_text_generator_compact_types (self , values , expectedType ):
74- text_gen1 = TextGenerator ()
84+ text_gen1 = self . TestTextGenerator ()
7585
7686 np_type = text_gen1 .compactNumpyTypeForValues (values )
7787 assert np_type == expectedType
0 commit comments