Best Python code snippet using pandera_python
test_numpy_engine.py
Source:test_numpy_engine.py
2import numpy as np3import pytest4from pandera.engines import numpy_engine5@pytest.mark.parametrize(6 "data_type", list(numpy_engine.Engine.get_registered_dtypes())7)8def test_numpy_data_type(data_type):9 """Test base numpy engine DataType."""10 numpy_engine.Engine.dtype(data_type)11 numpy_engine.Engine.dtype(data_type.type)12 numpy_engine.Engine.dtype(str(data_type.type))13 with pytest.warns(UserWarning):14 np_dtype = numpy_engine.DataType(data_type.type)15 with pytest.warns(UserWarning):16 np_dtype_from_str = numpy_engine.DataType(str(data_type.type))17 assert np_dtype == np_dtype_from_str18@pytest.mark.parametrize("data_type", ["foo", "bar", 1, 2, 3.14, np.void])19def test_numpy_engine_dtype_exceptions(data_type):20 """Test invalid inputs to numpy data-types."""...
test_pandas_engine.py
Source:test_pandas_engine.py
...3import pytest4from pandera.engines import pandas_engine5from pandera.errors import ParserError6@pytest.mark.parametrize(7 "data_type", list(pandas_engine.Engine.get_registered_dtypes())8)9def test_pandas_data_type(data_type):10 """Test numpy engine DataType base class."""11 if data_type.type is None:12 # don't test data types that require parameters e.g. Category13 return14 pandas_engine.Engine.dtype(data_type)15 pandas_engine.Engine.dtype(data_type.type)16 pandas_engine.Engine.dtype(str(data_type.type))17 with pytest.warns(UserWarning):18 pd_dtype = pandas_engine.DataType(data_type.type)19 with pytest.warns(UserWarning):20 pd_dtype_from_str = pandas_engine.DataType(str(data_type.type))21 assert pd_dtype == pd_dtype_from_str22 assert not pd_dtype.check("foo")23@pytest.mark.parametrize(24 "data_type", list(pandas_engine.Engine.get_registered_dtypes())25)26def test_pandas_data_type_coerce(data_type):27 """28 Test that pandas data type coercion will raise a ParserError. on failure.29 """30 if data_type.type is None:31 # don't test data types that require parameters e.g. Category32 return33 try:34 data_type().try_coerce(pd.Series(["1", "2", "a"]))35 except ParserError as exc:...
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!!