How to use skipIf method in avocado

Best Python code snippet using avocado_python

skip.py

Source:skip.py Github

copy

Full Screen

1# Licensed to the Apache Software Foundation (ASF) under one2# or more contributor license agreements. See the NOTICE file3# distributed with this work for additional information4# regarding copyright ownership. The ASF licenses this file5# to you under the Apache License, Version 2.0 (the6# "License"); you may not use this file except in compliance7# with the License. You may obtain a copy of the License at8#9# http://www.apache.org/licenses/LICENSE-2.010#11# Unless required by applicable law or agreed to in writing,12# software distributed under the License is distributed on an13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY14# KIND, either express or implied. See the License for the15# specific language governing permissions and limitations16# under the License.17#18# Impala py.test skipif markers. When a test can't be run against S3,19# choose the appropriate reason (or add a new one if needed) and20# annotate the class or test routine with the marker.21#22import os23import pytest24from functools import partial25from tests.common.environ import IMPALAD_BUILD26from tests.util.filesystem_utils import (27 IS_ADLS,28 IS_EC,29 IS_HDFS,30 IS_ISILON,31 IS_LOCAL,32 IS_S3,33 SECONDARY_FILESYSTEM)34class SkipIfS3:35 # These ones are skipped due to product limitations.36 caching = pytest.mark.skipif(IS_S3, reason="SET CACHED not implemented for S3")37 hive = pytest.mark.skipif(IS_S3, reason="Hive doesn't work with S3")38 hdfs_block_size = pytest.mark.skipif(IS_S3, reason="S3 uses it's own block size")39 hdfs_acls = pytest.mark.skipif(IS_S3, reason="HDFS acls are not supported on S3")40 jira = partial(pytest.mark.skipif, IS_S3)41 hdfs_encryption = pytest.mark.skipif(IS_S3,42 reason="HDFS encryption is not supported with S3")43 empty_directory = pytest.mark.skipif(IS_S3,44 reason="Empty directories are not supported on S3")45 # These ones need test infra work to re-enable.46 udfs = pytest.mark.skipif(IS_S3, reason="udas/udfs not copied to S3")47 datasrc = pytest.mark.skipif(IS_S3, reason="data sources not copied to S3")48 hbase = pytest.mark.skipif(IS_S3, reason="HBase not started with S3")49 qualified_path = pytest.mark.skipif(IS_S3,50 reason="Tests rely on HDFS qualified paths, IMPALA-1872")51class SkipIfADLS:52 # These ones are skipped due to product limitations.53 caching = pytest.mark.skipif(IS_ADLS, reason="SET CACHED not implemented for ADLS")54 hive = pytest.mark.skipif(IS_ADLS, reason="Hive doesn't work with ADLS")55 hdfs_block_size = pytest.mark.skipif(IS_ADLS, reason="ADLS uses it's own block size")56 hdfs_acls = pytest.mark.skipif(IS_ADLS, reason="HDFS acls are not supported on ADLS")57 jira = partial(pytest.mark.skipif, IS_ADLS)58 hdfs_encryption = pytest.mark.skipif(IS_ADLS,59 reason="HDFS encryption is not supported with ADLS")60 # These ones need test infra work to re-enable.61 udfs = pytest.mark.skipif(IS_ADLS, reason="udas/udfs not copied to ADLS")62 datasrc = pytest.mark.skipif(IS_ADLS, reason="data sources not copied to ADLS")63 hbase = pytest.mark.skipif(IS_ADLS, reason="HBase not started with ADLS")64 qualified_path = pytest.mark.skipif(IS_ADLS,65 reason="Tests rely on HDFS qualified paths, IMPALA-1872")66 eventually_consistent = pytest.mark.skipif(IS_ADLS,67 reason="The client is slow to realize changes to file metadata")68class SkipIfKudu:69 unsupported_env = pytest.mark.skipif(os.environ["KUDU_IS_SUPPORTED"] == "false",70 reason="Kudu is not supported in this environment")71class SkipIf:72 skip_hbase = pytest.mark.skipif(pytest.config.option.skip_hbase,73 reason="--skip_hbase argument specified")74 kudu_not_supported = pytest.mark.skipif(os.environ["KUDU_IS_SUPPORTED"] == "false",75 reason="Kudu is not supported")76 not_s3 = pytest.mark.skipif(not IS_S3, reason="S3 Filesystem needed")77 not_hdfs = pytest.mark.skipif(not IS_HDFS, reason="HDFS Filesystem needed")78 not_ec = pytest.mark.skipif(not IS_EC, reason="Erasure Coding needed")79 no_secondary_fs = pytest.mark.skipif(not SECONDARY_FILESYSTEM,80 reason="Secondary filesystem needed")81class SkipIfIsilon:82 caching = pytest.mark.skipif(IS_ISILON, reason="SET CACHED not implemented for Isilon")83 hbase = pytest.mark.skipif(IS_ISILON, reason="HBase not tested with Isilon")84 hive = pytest.mark.skipif(IS_ISILON, reason="Hive not tested with Isilon")85 hdfs_acls = pytest.mark.skipif(IS_ISILON, reason="HDFS acls are not supported on Isilon")86 hdfs_block_size = pytest.mark.skipif(IS_ISILON,87 reason="Isilon uses its own block size")88 hdfs_encryption = pytest.mark.skipif(IS_ISILON,89 reason="HDFS encryption is not supported with Isilon")90 untriaged = pytest.mark.skipif(IS_ISILON,91 reason="This Isilon issue has yet to be triaged.")92 jira = partial(pytest.mark.skipif, IS_ISILON)93class SkipIfLocal:94 # These ones are skipped due to product limitations.95 caching = pytest.mark.skipif(IS_LOCAL,96 reason="HDFS caching not supported on local file system")97 hdfs_blocks = pytest.mark.skipif(IS_LOCAL,98 reason="Files on local filesystem are not split into blocks")99 hdfs_encryption = pytest.mark.skipif(IS_LOCAL,100 reason="HDFS encryption is not supported on local filesystem")101 hive = pytest.mark.skipif(IS_LOCAL,102 reason="Hive not started when using local file system")103 multiple_impalad = pytest.mark.skipif(IS_LOCAL,104 reason="Multiple impalads are not supported when using local file system")105 parquet_file_size = pytest.mark.skipif(IS_LOCAL,106 reason="Parquet block size incorrectly determined")107 hdfs_fd_caching = pytest.mark.skipif(IS_LOCAL,108 reason="HDFS file handle caching not supported for local non-HDFS files")109 # These ones need test infra work to re-enable.110 hbase = pytest.mark.skipif(IS_LOCAL,111 reason="HBase not started when using local file system")112 hdfs_client = pytest.mark.skipif(IS_LOCAL,113 reason="HDFS not started when using local file system")114 qualified_path = pytest.mark.skipif(IS_LOCAL,115 reason="Tests rely on HDFS qualified paths")116 root_path = pytest.mark.skipif(IS_LOCAL,117 reason="Tests rely on the root directory")118class SkipIfNotHdfsMinicluster:119 # These ones are skipped when not running against a local HDFS mini-cluster.120 plans = pytest.mark.skipif(not IS_HDFS or pytest.config.option.testing_remote_cluster,121 reason="Test assumes plans from local HDFS mini-cluster")122 tuned_for_minicluster = pytest.mark.skipif(123 not IS_HDFS or IS_EC or pytest.config.option.testing_remote_cluster,124 reason="Test is tuned for 3-node HDFS minicluster with no EC")125class SkipIfBuildType:126 not_dev_build = pytest.mark.skipif(not IMPALAD_BUILD.is_dev(),127 reason="Tests depends on debug build startup option.")128class SkipIfEC:129 remote_read = pytest.mark.skipif(IS_EC, reason="EC files are read remotely and "130 "features relying on local read do not work.")131 oom = pytest.mark.skipif(IS_EC, reason="Probably broken by HDFS-13540.")...

Full Screen

Full Screen

test_ext_doctest.py

Source:test_ext_doctest.py Github

copy

Full Screen

1"""2 test_doctest3 ~~~~~~~~~~~~4 Test the doctest extension.5 :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.6 :license: BSD, see LICENSE for details.7"""8import os9from collections import Counter10from docutils import nodes11import pytest12from packaging.specifiers import InvalidSpecifier13from packaging.version import InvalidVersion14from sphinx.ext.doctest import is_allowed_version15cleanup_called = 016@pytest.mark.sphinx('doctest', testroot='ext-doctest')17def test_build(app, status, warning):18 global cleanup_called19 cleanup_called = 020 app.builder.build_all()21 if app.statuscode != 0:22 assert False, 'failures in doctests:' + status.getvalue()23 # in doctest.txt, there are two named groups and the default group,24 # so the cleanup function must be called three times25 assert cleanup_called == 3, 'testcleanup did not get executed enough times'26@pytest.mark.sphinx('dummy', testroot='ext-doctest')27def test_highlight_language_default(app, status, warning):28 app.build()29 doctree = app.env.get_doctree('doctest')30 for node in doctree.traverse(nodes.literal_block):31 assert node['language'] in ('python3', 'pycon3', 'none')32@pytest.mark.sphinx('dummy', testroot='ext-doctest',33 confoverrides={'highlight_language': 'python'})34def test_highlight_language_python2(app, status, warning):35 app.build()36 doctree = app.env.get_doctree('doctest')37 for node in doctree.traverse(nodes.literal_block):38 assert node['language'] in ('python', 'pycon', 'none')39def test_is_allowed_version():40 assert is_allowed_version('<3.4', '3.3') is True41 assert is_allowed_version('<3.4', '3.3') is True42 assert is_allowed_version('<3.2', '3.3') is False43 assert is_allowed_version('<=3.4', '3.3') is True44 assert is_allowed_version('<=3.2', '3.3') is False45 assert is_allowed_version('==3.3', '3.3') is True46 assert is_allowed_version('==3.4', '3.3') is False47 assert is_allowed_version('>=3.2', '3.3') is True48 assert is_allowed_version('>=3.4', '3.3') is False49 assert is_allowed_version('>3.2', '3.3') is True50 assert is_allowed_version('>3.4', '3.3') is False51 assert is_allowed_version('~=3.4', '3.4.5') is True52 assert is_allowed_version('~=3.4', '3.5.0') is True53 # invalid spec54 with pytest.raises(InvalidSpecifier):55 is_allowed_version('&3.4', '3.5')56 # invalid version57 with pytest.raises(InvalidVersion):58 is_allowed_version('>3.4', 'Sphinx')59def cleanup_call():60 global cleanup_called61 cleanup_called += 162recorded_calls = Counter()63@pytest.mark.sphinx('doctest', testroot='ext-doctest-skipif')64def test_skipif(app, status, warning):65 """Tests for the :skipif: option66 The tests are separated into a different test root directory since the67 ``app`` object only evaluates options once in its lifetime. If these tests68 were combined with the other doctest tests, the ``:skipif:`` evaluations69 would be recorded only on the first ``app.builder.build_all()`` run, i.e.70 in ``test_build`` above, and the assertion below would fail.71 """72 global recorded_calls73 recorded_calls = Counter()74 app.builder.build_all()75 if app.statuscode != 0:76 assert False, 'failures in doctests:' + status.getvalue()77 # The `:skipif:` expressions are always run.78 # Actual tests and setup/cleanup code is only run if the `:skipif:`79 # expression evaluates to a False value.80 # Global setup/cleanup are run before/after evaluating the `:skipif:`81 # option in each directive - thus 11 additional invocations for each on top82 # of the ones made for the whole test file.83 assert recorded_calls == {('doctest_global_setup', 'body', True): 13,84 ('testsetup', ':skipif:', True): 1,85 ('testsetup', ':skipif:', False): 1,86 ('testsetup', 'body', False): 1,87 ('doctest', ':skipif:', True): 1,88 ('doctest', ':skipif:', False): 1,89 ('doctest', 'body', False): 1,90 ('testcode', ':skipif:', True): 1,91 ('testcode', ':skipif:', False): 1,92 ('testcode', 'body', False): 1,93 ('testoutput-1', ':skipif:', True): 1,94 ('testoutput-2', ':skipif:', True): 1,95 ('testoutput-2', ':skipif:', False): 1,96 ('testcleanup', ':skipif:', True): 1,97 ('testcleanup', ':skipif:', False): 1,98 ('testcleanup', 'body', False): 1,99 ('doctest_global_cleanup', 'body', True): 13}100def record(directive, part, should_skip):101 global recorded_calls102 recorded_calls[(directive, part, should_skip)] += 1103 return 'Recorded {} {} {}'.format(directive, part, should_skip)104@pytest.mark.sphinx('doctest', testroot='ext-doctest-with-autodoc')105def test_reporting_with_autodoc(app, status, warning, capfd):106 # Patch builder to get a copy of the output107 written = []108 app.builder._warn_out = written.append109 app.builder.build_all()110 lines = '\n'.join(written).replace(os.sep, '/').split('\n')111 failures = [l for l in lines if l.startswith('File')]112 expected = [113 'File "dir/inner.rst", line 1, in default',114 'File "dir/bar.py", line ?, in default',115 'File "foo.py", line ?, in default',116 'File "index.rst", line 4, in default',117 ]118 for location in expected:...

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 avocado 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