Best Python code snippet using pandera_python
test_attributes.py
Source: test_attributes.py
...37 self.assertEqual(attr.coerce(1), '1')38 self.assertEqual(attr.coerce('1'), '1')39 self.assertEqual(attr.coerce('Ã'), 'Ã')40 self.assertRaises(NullSalesforceColumnError, attr.coerce, None)41 def test_nullable(self):42 attr = attributes.String('Attr', nullable=True)43 self.assertIsNone(attr.coerce(None))44 def test_serialize(self):45 attr = attributes.String('Attr')46 self.assertEqual(attr.serialize('1'), '1')47class IntegerTest(unittest.TestCase):48 def test_coerce(self):49 attr = attributes.Integer('Attr')50 self.assertEqual(attr.coerce('1'), 1)51 self.assertEqual(attr.coerce(1), 1)52 self.assertRaises(NullSalesforceColumnError, attr.coerce, None)53 def test_nullable(self):54 attr = attributes.Integer('Attr', nullable=True)55 self.assertIsNone(attr.coerce(None))56 def test_serialize(self):57 attr = attributes.Integer('Attr')58 self.assertEqual(attr.serialize(1), 1)59class FloatTest(unittest.TestCase):60 def test_coerce(self):61 attr = attributes.Float('Attr')62 self.assertEqual(attr.coerce('1.0'), 1.0)63 self.assertEqual(attr.coerce(1.0), 1.0)64 def test_nullable(self):65 attr = attributes.Float('Attr', nullable=True)66 self.assertIsNone(attr.coerce(None))67 def test_serialize(self):68 attr = attributes.Float('Attr')69 self.assertEqual(attr.serialize(1.1), 1.1)70class BooleanTest(unittest.TestCase):71 def test_coerce(self):72 attr = attributes.Boolean('Attr')73 self.assertEqual(attr.coerce(True), True)74 self.assertEqual(attr.coerce(False), False)75 self.assertRaises(NullSalesforceColumnError, attr.coerce, None)76 def test_nullable(self):77 attr = attributes.Boolean('Attr', nullable=True)78 self.assertIsNone(attr.coerce(None))79 def test_serialize(self):80 attr = attributes.Boolean('Attr')81 self.assertEqual(attr.serialize(True), True)82class DateTimeTest(unittest.TestCase):83 def test_coerce(self):84 attr = attributes.DateTime('Attr')85 datetime_ = datetime(year=1990, month=10, day=19, tzinfo=tzutc())86 date_ = date(year=1990, month=10, day=19)87 self.assertEqual(attr.coerce(datetime_), datetime_)88 self.assertEqual(attr.coerce(datetime_.isoformat()), datetime_)89 self.assertEqual(attr.coerce(datetime_.replace(tzinfo=None)), datetime_)90 self.assertEqual(attr.coerce(date_), datetime_)91 tz_naive_string = datetime_.replace(tzinfo=None).isoformat()92 self.assertEqual(attr.coerce(tz_naive_string), datetime_)93 self.assertRaises(NullSalesforceColumnError, attr.coerce, None)94 def test_nullable(self):95 attr = attributes.DateTime('Attr', nullable=True)96 self.assertIsNone(attr.coerce(None))97 def test_serialize(self):98 datetime_ = datetime(year=1990, month=10, day=19, tzinfo=tzutc())99 attr = attributes.DateTime('Attr')100 self.assertEqual(attr.serialize(datetime_), datetime_.isoformat())101class DateTest(unittest.TestCase):102 def test_coerce(self):103 attr = attributes.Date('Attr')104 datetime_ = datetime(year=1990, month=10, day=19, hour=5, tzinfo=tzutc())105 date_ = date(year=1990, month=10, day=19)106 self.assertEqual(attr.coerce(date_), date_)107 self.assertEqual(attr.coerce(date_.isoformat()), date_)108 self.assertEqual(attr.coerce(datetime_), date_)109 self.assertRaises(NullSalesforceColumnError, attr.coerce, None)110 def test_nullable(self):111 attr = attributes.Date('Attr', nullable=True)112 self.assertIsNone(attr.coerce(None))113 def test_serialize(self):114 date_ = date(year=1990, month=10, day=19)115 attr = attributes.Date('Attr')...
test_yaml.py
Source: test_yaml.py
...32 def test_float(self, loaded):33 assert loaded["section"]["float"] == 3.1434 def test_int(self, loaded):35 assert loaded["section"]["int"] == 25536 def test_nullable(self, loaded):37 assert loaded["section"]["nullable"] is None38 def test_str(self, loaded):39 assert loaded["section"]["str"] == "foo bar"40 def test_array(self, loaded):41 assert loaded["section"]["array"] == [0, 1, 2]42 def test_nested(self, loaded):43 assert loaded["section"]["nested"]["int"] == 1044class TestDump(BaseTestIODump):45 module = yaml46 def test_section(self, dumped):47 assert "section:\n" in dumped48 def test_bool(self, dumped):49 assert "bool: true\n" in dumped50 def test_custom(self, dumped):51 assert "custom: by custom" in dumped52 def test_datetime(self, dumped):53 assert re.search(54 r"\s+datetime: '2019-05-27T10:00:00(\.0*)?-07:00'(\n|$)", dumped55 )56 def test_float(self, dumped):57 assert "float: 3.14\n" in dumped58 def test_int(self, dumped):59 assert "int: 255\n" in dumped60 def test_nullable(self, dumped):61 assert "nullable: null\n" in dumped62 def test_str(self, dumped):...
test_config.py
Source: test_config.py
1# -*- coding: utf-8 -*-2#3# tests/cli.py4#5# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.6#7# Licensed under the Apache License, Version 2.0 (the "License");8# you may not use this file except in compliance with the License.9# You may obtain a copy of the License at10#11# http://www.apache.org/licenses/LICENSE-2.012#13# Unless required by applicable law or agreed to in writing, software14# distributed under the License is distributed on an "AS IS" BASIS,15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16# See the License for the specific language governing permissions and17# limitations under the License.18#19import os20import pytest21from cfn_tools._config import config, apply_configs, _CONFIG_DEFAULTS, _ConfigArg, _Config22def test_config_rest():23 assert config.reset() is None24def test_config_rest_with_item():25 assert config.reset("max_col_width") is None26def test_config_with_env_var():27 os.environ["CFN_MAX_COL_WIDTH"] = "200"28 assert config.reset() is None29 del os.environ["CFN_MAX_COL_WIDTH"]30def test_config_get_item():31 assert config['max_col_width'] == 20032def test_invalid_config_set_attr():33 with pytest.raises(TypeError):34 config.invalid_entry = "200"35def test_config_apply_configs():36 @apply_configs37 def temp_my_func(max_col_width):38 return max_col_width39 assert temp_my_func() == 20040def test_config_apply_type_null():41 _CONFIG_DEFAULTS['test_nullable'] = _ConfigArg(dtype=bool, nullable=True, has_default=False)42 test_config = _Config()43 test_config.test_nullable = None44 assert test_config.test_nullable is None45def test_config_apply_type_null_error():46 _CONFIG_DEFAULTS['test_nullable'] = _ConfigArg(dtype=int, nullable=False, has_default=True, default="nil")47 with pytest.raises(ValueError):...
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!!