Skip to content

Latest commit

 

History

History

tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Testing oelint-adv

Installing test dependencies

pip3 install -r requirements-dev.txt

oelint-adv tests are built around pytest. Running pytest will execute all available tests. Note, that test fail when coverage drops below 100 %.

Adding a new test

Every test is organized in test classes derived from TestBaseClass

from .base import TestBaseClass

class TestClassMyNewTests(TestBaseClass):
    ...

now functions prefixed with test_ can be added to this class

from .base import TestBaseClass

class TestClassMyNewTests(TestBaseClass):
    
    def test_mynewtest(self):
        ...

TestBaseClass

Creating CLI arguments

to create the CLI arguments for oelint-adv use

self._create_args(input_)

_input is a dictionary of filenames and content.

The _create_args function will then create temporary files with said content.

Optional arguments can be passed as a list of strings using

self._create_args(input_, ['my', 'extra', 'arguments'])

Checking for a finding

To check if a finding was found check_for_id can be used

self.check_for_id(arguments, id_to_check_for, number_of_occurrences)

e.g.

self.check_for_id(self._create_args(input_), 'oelint.exportfunction.dash', 1)

checks the input an tests if the provided input file(s) produce exactly one report of oelint.exportfunction.dash

Test automatic fixing

To test if automated fixing is working fix_and_check can be used

e.g.

self.fix_and_check(self._create_args(input_), 'oelint.exportfunction.dash')

test if after automatic fixing exactly no reports of oelint.exportfunction.dash are found

Using pytest.parametrize

to test different variation of inputs, pytest.parametrize is used widely

e.g.

@pytest.mark.parametrize('id_', ['oelint.file.includenotfound'])
@pytest.mark.parametrize('occurrence', [1])
@pytest.mark.parametrize('input_',
                            [
                                {
                                    'oelint_adv_test.bb': 'include oelint_adv_test.inc',
                                },
                                {
                                    'oelint_adv_test.bb': 'include oelint_adv_test2.inc',
                                },
                            ],
                            )
def test_bad(self, input_, id_, occurrence):
    self.check_for_id(self._create_args(input_), id_, occurrence)

would run the check for all instances of inputs found in @pytest.mark.parametrize('input_'.

This can be used to reduce the amount of test functions written. Pytest will automatically generate instance for all permutations of configured inputs.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy