Best Python code snippet using localstack_python
test_helpers.py
Source:test_helpers.py
1import pandas as pd2from python_utilities import utils, testing, dataframes # noqa3def test_format_bytes():4 assert utils.format_bytes(5368709120) == "5.0GB"5 assert utils.format_bytes(1024) == "1.0KB"6 assert utils.format_bytes(124213) == "121.3KB"7def test_is_pandas_df():8 assert utils.is_pandas_df(testing.get_test_example())9 assert not utils.is_pandas_df([12, 123])10def test_is_dask_df():11 pandas_df = testing.get_test_example()12 dask_df = dataframes.convert_pandas_to_dask(pandas_df)13 assert utils.is_dask_df(dask_df)14 assert not utils.is_dask_df(pandas_df)15def test_is_list():16 assert utils.is_list([1, 2, 3])17 assert not utils.is_list("123")18def test_is_string():19 assert utils.is_string("12321")20 assert not utils.is_string([1, 2, 3])21def test_is_datetime_series():22 example = pd.Series(23 [24 "2020-01-08",25 "2020-01-09",26 "2020-01-10",27 "2020-01-11",28 "2020-01-06",29 "2020-01-07",30 "2020-01-08",31 "2020-01-09",32 ]33 )34 assert not utils.is_datetime_series(example)35 example = pd.to_datetime(example)36 assert utils.is_datetime_series(example)37def test_ensure_is_list():38 assert utils.ensure_is_list(123) == [123]39 assert utils.ensure_is_list([123]) == [123]40def test_correct_suffixes_in_list():41 pandas_df = testing.get_test_example()42 answer = list(pandas_df.columns).copy()43 result = utils.correct_suffixes_in_list(pandas_df, pandas_df.columns)44 assert result == answer45 index_list = [col + "_index" for col in pandas_df.columns]46 result = utils.correct_suffixes_in_list(pandas_df, index_list)47 assert result == answer48if __name__ == "__main__":49 test_format_bytes()50 test_is_pandas_df()51 test_is_dask_df()52 test_is_list()53 test_is_string()54 test_is_datetime_series()55 test_ensure_is_list()...
unittest_checker_strings.py
Source:unittest_checker_strings.py
...6from pylint.checkers import strings7from pylint.testutils import CheckerTestCase8class TestStringChecker(CheckerTestCase):9 CHECKER_CLASS = strings.StringFormatChecker10 def test_format_bytes(self):11 code = "b'test'.format(1, 2)"12 node = astroid.extract_node(code)13 with self.assertNoMessages():...
test_util.py
Source:test_util.py
1from src import util2def test_format_bytes():3 assert util.format_bytes(0) == '0 B'4 assert util.format_bytes(999) == '999 B'5 assert util.format_bytes(1_000) == '1.0 KB'6 assert util.format_bytes(999_000) == '999.0 KB'7 assert util.format_bytes(1_000_000) == '1.0 MB'8 assert util.format_bytes(999_000_000) == '999.0 MB'9 assert util.format_bytes(1_000_000_000) == '1.0 GB'10 assert util.format_bytes(1_500_000_000) == '1.5 GB'11def test_format_bytes_none():...
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!!