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:
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
Development practices are constantly changing and as testers, we need to embrace change. One of the changes that we can experience is the move from monthly or quarterly releases to continuous delivery or continuous deployment. This move to continuous delivery or deployment offers testers the chance to learn new skills.
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!!