Best Python code snippet using pandera_python
test_blogger.py
Source: test_blogger.py
...19 """20 Test on good date string on Central and East Europe21 """22 date = "2000-01-01T00:00:00.001+01:00"23 self.assertTrue(self.vimb._check_date(date))24 def test_happy_case_HST(self):25 """26 Test on good date string on Hawaii Time Zone27 """28 date = "2000-01-01T00:00:00.001-10:00"29 self.assertTrue(self.vimb._check_date(date))30 def test_happy_case_GMT(self):31 """32 Test UTC date string33 """34 date = "2000-01-01T00:00:00.001-00:00"35 self.assertTrue(self.vimb._check_date(date))36 def test_without_milliseconds(self):37 """38 Test on date string without milliseconds39 """40 date = "2000-01-01T00:00:00+01:00"41 self.assertTrue(self.vimb._check_date(date))42 def test_wrong_tz_format(self):43 """44 Test date with wrong timezone format (hour have no leading 0)45 """46 date = "2000-01-01T00:00:00.001+1:00"47 self.assertFalse(self.vimb._check_date(date))48 # Test date with wrong timezone format (minute have only one digit)49 date = "2000-01-01T00:00:00.001+01:0"50 self.assertFalse(self.vimb._check_date(date))51 # Test date with wrong timezone format (hours and minutes hasn't been52 # separated by colon)53 date = "2000-01-01T00:00:00.001+0100"54 self.assertFalse(self.vimb._check_date(date))55 def test_wrong_milliseconds(self):56 """57 Test date with wrong format of milliseconds (.01 instead of .010)58 """59 date = "2000-01-01T00:00:00.01+01:00"60 self.assertFalse(self.vimb._check_date(date))61 # Test date with wrong format of milliseconds (.1 instead of .100)62 date = "2000-01-01T00:00:00.1+01:00"63 self.assertFalse(self.vimb._check_date(date))64 # Test date with spolied format (dot for milliseconds, but no digits)65 date = "2000-01-01T00:00:00.+01:00"66 self.assertFalse(self.vimb._check_date(date))67 def test_good_milliseconds(self):68 """69 Test date with correct format of milliseconds70 """71 date = "2000-01-01T00:00:00.000+01:00"72 self.assertTrue(self.vimb._check_date(date), date + " is incorrect")73 date = "2000-01-01T00:00:00.999+01:00"74 self.assertTrue(self.vimb._check_date(date), date + " is incorrect")75 def test_wrong_hours(self):76 """77 Test date with wrong hours value78 """79 date = "2000-01-01T24:00:00.001+01:00"80 self.assertFalse(self.vimb._check_date(date))81 def test_good_hours(self):82 """83 Test date with correct hours values84 """85 date = "2000-01-01T00:00:00.001+01:00"86 self.assertTrue(self.vimb._check_date(date), date + " is incorrect")87 date = "2000-01-01T23:00:00.001+01:00"88 self.assertTrue(self.vimb._check_date(date), date + " is incorrect")89 def test_wrong_minutes(self):90 """91 Test date with wrong minutes value92 """93 date = "2000-01-01T00:60:00.001+01:00"94 self.assertFalse(self.vimb._check_date(date))95 date = "2000-01-01T00:000:00.001+01:00"96 self.assertFalse(self.vimb._check_date(date))97 date = "2000-01-01T00:1:00.001+01:00"98 self.assertFalse(self.vimb._check_date(date))99 def test_good_minutes(self):100 """101 Test date with correct minutes values102 """103 date = "2000-01-01T00:01:00.001+01:00"104 self.assertTrue(self.vimb._check_date(date))105 date = "2000-01-01T00:59:00.001+01:00"106 self.assertTrue(self.vimb._check_date(date))107 def test_wrong_seconds(self):108 """109 Test date with wrong seconds value110 """111 date = "2000-01-01T00:00:60.001+01:00"112 self.assertFalse(self.vimb._check_date(date))113 def test_good_seconds(self):114 """115 Test date with good seconds values116 """117 for second in range(60):118 date = "2000-01-01T00:00:%0.2d.001+01:00" % second119 self.assertTrue(self.vimb._check_date(date))120 def test_wrong_days(self):121 """122 Test date with incorrect days (january has always 31 days, no month123 has lower number than 1)124 """125 date = "2000-01-32T00:00:00.001+01:00"126 self.assertFalse(self.vimb._check_date(date))127 date = "2000-01-00T00:00:00.001+01:00"128 self.assertFalse(self.vimb._check_date(date))129 def test_good_days(self):130 """131 Test date with correct days (january has always 31 days)132 """133 date = "2000-01-01T00:00:00.001+01:00"134 self.assertTrue(self.vimb._check_date(date))135 date = "2000-01-31T00:00:00.001+01:00"136 self.assertTrue(self.vimb._check_date(date))137 def test_wrong_month(self):138 """139 Test date with wrong month140 """141 date = "2000-00-01T00:00:00.001+01:00"142 self.assertFalse(self.vimb._check_date(date))143 date = "2000-13-01T00:00:00.001+01:00"144 self.assertFalse(self.vimb._check_date(date))145 date = "2000-1-01T00:00:00.001+01:00"146 self.assertFalse(self.vimb._check_date(date))147 date = "2000-001-01T00:00:00.001+01:00"148 self.assertFalse(self.vimb._check_date(date))149 def test_good_month(self):150 """151 Test date with correct months152 """153 date = "2000-01-01T00:00:00.001+01:00"154 self.assertTrue(self.vimb._check_date(date))155 date = "2000-12-01T00:00:00.001+01:00"156 self.assertTrue(self.vimb._check_date(date))157 def test_wrong_year(self):158 """159 Test date with wrong year160 """161 date = "0000-01-01T00:00:00.001+01:00"162 self.assertFalse(self.vimb._check_date(date))163 date = "10000-01-01T00:00:00.001+01:00"164 self.assertFalse(self.vimb._check_date(date))165 date = "900-01-01T00:00:00.001+01:00"166 self.assertFalse(self.vimb._check_date(date))167 def test_good_year(self):168 """169 Test date with correct years170 """171 date = "0001-01-01T00:00:00.001+01:00"172 self.assertTrue(self.vimb._check_date(date))173 date = "9999-01-01T00:00:00.001+01:00"174 self.assertTrue(self.vimb._check_date(date))175class TestAuthorize(unittest.TestCase):176 """177 Test method VimBlogger._authorize178 """179 def setUp(self):180 """181 Create VimBlogger object (with good credentials, yes :>)182 """183 self.vimob = VimBlogger(None, shared.LOGIN, shared.PASS)184 def test_happy_case(self):185 """186 Try to login with good credentials187 """188 self.assertTrue(self.vimob._authorize(shared.LOGIN,...
wgmonthbox.py
Source: wgmonthbox.py
...20 return datetime.datetime21 else:22 return datetime.date23 24 def _check_date(self):25 if not self.value:26 return None27 if not self.allow_date_in_past:28 if self.value < self.date_or_datetime().today():29 if self.allow_todays_date:30 self.value = self.date_or_datetime().today()31 else:32 self.value = self.date_or_datetime().today() + datetime.timedelta(1) 33 34 def _check_today_validity(self, onErrorHigher=True):35 """If not allowed to select today's date, and today is selected, move either higher or lower36depending on the value of onErrorHigher"""37 if not self.allow_date_in_past:38 onErrorHigher = True39 if self.allow_todays_date:40 return True41 else:42 if self.value == self.date_or_datetime().today():43 if onErrorHigher:44 self.value += datetime.timedelta(1)45 else:46 self.value -= datetime.timedelta(1)47 48 49 def set_up_handlers(self):50 super(DateEntryBase, self).set_up_handlers()51 self.handlers.update({ "D": self.h_day_less,52 "d": self.h_day_more,53 "W": self.h_week_less,54 "w": self.h_week_more,55 "M": self.h_month_less,56 "m": self.h_month_more,57 "Y": self.h_year_less,58 "y": self.h_year_more,59 "t": self.h_find_today,60 "q": self.h_clear,61 "c": self.h_clear,62 })63 def _reduce_value_by_delta(self, delta):64 old_value = self.value65 try:66 self.value -= delta67 except:68 self.value = old_value69 70 def _increase_value_by_delta(self, delta):71 old_value = self.value72 try:73 self.value += delta74 except:75 self.value = old_value76 77 78 def h_day_less(self, *args):79 self._reduce_value_by_delta(datetime.timedelta(1))80 self._check_date()81 self._check_today_validity(onErrorHigher=False)82 def h_day_more(self, *args):83 self._increase_value_by_delta(datetime.timedelta(1))84 self._check_date()85 self._check_today_validity(onErrorHigher=True)86 87 def h_week_less(self, *args):88 self._reduce_value_by_delta(datetime.timedelta(7))89 self._check_date()90 self._check_today_validity(onErrorHigher=False)91 92 def h_week_more(self, *args):93 self._increase_value_by_delta(datetime.timedelta(7))94 self._check_date()95 self._check_today_validity(onErrorHigher=True)96 def h_month_less(self, *args):97 self._reduce_value_by_delta(datetime.timedelta(28))98 self._check_date()99 self._check_today_validity(onErrorHigher=False)100 101 def h_month_more(self, *args):102 self._increase_value_by_delta(datetime.timedelta(28))103 self._check_date()104 self._check_today_validity(onErrorHigher=True)105 def h_year_less(self, *args):106 old_value = self.value107 try:108 if self.value.month == 2 and self.value.day == 29:109 self.value = self.value.replace(year=self.value.year-1, day=self.value.day-1)110 else:111 self.value = self.value.replace(year=self.value.year-1)112 self._check_date()113 self._check_today_validity(onErrorHigher=False)114 except:115 self.value=old_value116 def h_year_more(self, *args):117 old_value = self.value118 try:119 if self.value.month == 2 and self.value.day == 29:120 self.value = self.value.replace(year=self.value.year+1, day=self.value.day-1)121 else:122 self.value = self.value.replace(year=self.value.year+1)123 self._check_date()124 self._check_today_validity(onErrorHigher=True)125 except:126 self.value = old_value127 128 def h_find_today(self, *args):129 self.value = self.date_or_datetime().today() 130 self._check_date()131 self._check_today_validity(onErrorHigher=True)132 133 def h_clear(self, *args):134 if self.allow_clear:135 self.value = None136 self.editing = None 137class MonthBox(DateEntryBase):138 DAY_FIELD_WIDTH = 4139 140 def __init__(self, screen, **keywords):141 super(MonthBox, self).__init__(screen, **keywords)142 143 def calculate_area_needed(self):144 # Rember that although months only have 4-5 weeks, they can span 6 weeks....
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!