How to use _write_yaml method in pandera

Best Python code snippet using pandera_python

base.py

Source:base.py Github

copy

Full Screen

...147}148NO_CONF = {149 'cache': {'max_age': 1},150}151def _write_yaml(obj):152 # Assume NestedTempfile so we don't have to cleanup153 with tempfile.NamedTemporaryFile(delete=False) as obj_yaml:154 obj_yaml.write(yaml.safe_dump(obj).encode('utf-8'))155 return obj_yaml.name156class TestCase(base.BaseTestCase):157 """Test case base class for all unit tests."""158 def setUp(self):159 super(TestCase, self).setUp()160 self.useFixture(fixtures.NestedTempfile())161 conf = copy.deepcopy(USER_CONF)162 tdir = self.useFixture(fixtures.TempDir())163 conf['cache']['path'] = tdir.path164 self.cloud_yaml = _write_yaml(conf)165 self.secure_yaml = _write_yaml(SECURE_CONF)166 self.vendor_yaml = _write_yaml(VENDOR_CONF)167 self.no_yaml = _write_yaml(NO_CONF)168 # Isolate the test runs from the environment169 # Do this as two loops because you can't modify the dict in a loop170 # over the dict in 3.4171 keys_to_isolate = []172 for env in os.environ.keys():173 if env.startswith('OS_'):174 keys_to_isolate.append(env)175 for env in keys_to_isolate:176 self.useFixture(fixtures.EnvironmentVariable(env))177 def _assert_cloud_details(self, cc):178 self.assertIsInstance(cc, cloud_config.CloudConfig)179 self.assertTrue(extras.safe_hasattr(cc, 'auth'))180 self.assertIsInstance(cc.auth, dict)181 self.assertIsNone(cc.cloud)...

Full Screen

Full Screen

test_config_base.py

Source:test_config_base.py Github

copy

Full Screen

...72 def setUp(self):73 self.tempdir = tempfile.mkdtemp()74 def tearDown(self):75 shutil.rmtree(self.tempdir)76 def _write_yaml(self, thing=None):77 if thing is None:78 thing = dict(a=1, b=2, c=3, d=4)79 fd, f = tempfile.mkstemp(suffix='yaml', dir=self.tempdir)80 os.close(fd)81 with open(f, 'wb') as fd:82 yaml.dump(thing, fd)83 return thing, f84 def test_parse_yaml(self):85 thing, f = self._write_yaml()86 self.assertTrue(os.path.exists(f))87 self.assertTrue(os.path.getsize(f) > 0)88 from_yaml = config.parse_yaml(f)89 self.assertEqual(thing, from_yaml)90 def test_config_init(self):91 thing, f = self._write_yaml()92 c = config.Config(f)93 self.assertEqual(f, c.file)94 self.assertEqual(thing, c.config)95 def test_validate(self):96 dummy, f = self._write_yaml()97 c = config.Config(f)98 # add some validations99 c.validations.append(_counter)100 c.validations.append(_counter)101 c.validations.append(_counter)102 # confirm that each validation got run103 self.assertEqual(0, _count)104 c.validate()105 self.assertEqual(3, _count)106 def test_load(self):107 dummy, f = self._write_yaml()108 os.remove(f)109 c = config.Config(f)110 self.assertEqual(None, c.config)111 c.load()112 # nothing should have happened113 self.assertEqual(None, c.config)114 # write another yaml file115 thing, f = self._write_yaml()116 # sub the new file name117 c.file = f118 # load it119 c.load()120 # we should get the thing back again121 self.assertEqual(thing, c.config)122 # load should add each of the things as123 # config attributes124 for k, v in thing.iteritems():125 self.assertTrue(hasattr(c, k))126 self.assertEqual(c.__getattribute__(k), v)127if __name__ == "__main__":128 #import sys;sys.argv = ['', 'Test.testName']129 unittest.main()

Full Screen

Full Screen

settings.py

Source:settings.py Github

copy

Full Screen

...7 with open(fn) as f:8 self._data = yaml.load(f)9 else:10 self._data = {}11 def _write_yaml(self):12 with open(self._fn, 'w') as f:13 yaml.dump(self._data, f, default_flow_style=False)14 def __len__(self):15 return len(self._data)16 def __getitem__(self, key):17 return self._data[key]18 def __setitem__(self, key, value):19 self._data[key] = value20 self._write_yaml()21 def __delitem__(self, key):22 del self._data[key]23 self._write_yaml()24 def __iter__(self):25 yield from self._data26 def __contains__(self, item):27 return item in self._data28 def __repr__(self):29 return str(self)30 def __str__(self):...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pandera automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful