<commit_before>import pytest
import dukpy

from detectem.core import Detector
from detectem.plugin import load_plugins, get_plugin_by_name

from tests import load_from_yaml, tree


class TestGenericMatches(object):
    @pytest.fixture()
    def plugin_list(self):
        return load_plugins()

    def pytest_generate_tests(self, metafunc):
        fname = metafunc.function.__name__

        plugin = pytest.config.getoption('plugin', None)
        if plugin:
            plugin = plugin.replace('.', '')
            data = load_from_yaml(__file__, 'fixtures/{}.yml'.format(plugin))
        else:
            data = load_from_yaml(__file__, 'fixtures/')

        if fname == 'test_matches':
            cases = []
            for entry in data:
                for match in entry['matches']:
                    cases.append([entry['plugin'], match])

            metafunc.parametrize('plugin_name,match', cases)
        elif fname == 'test_js_matches':
            cases = []
            for entry in data:
                for match in entry.get('js_matches', []):
                    cases.append([entry['plugin'], match])

            metafunc.parametrize('plugin_name,match', cases)


    def test_matches(self, plugin_name, match, plugin_list):
        fake_har_entry = tree()
        if 'url' in match:
            method = Detector.get_version_from_url
            fake_har_entry['request']['url'] = match['url']<commit_msg>Fix tests without normal matches<commit_after>import pytest
import dukpy

from detectem.core import Detector
from detectem.plugin import load_plugins, get_plugin_by_name

from tests import load_from_yaml, tree


class TestGenericMatches(object):
    @pytest.fixture()
    def plugin_list(self):
        return load_plugins()

    def pytest_generate_tests(self, metafunc):
        fname = metafunc.function.__name__

        plugin = pytest.config.getoption('plugin', None)
        if plugin:
            plugin = plugin.replace('.', '')
            data = load_from_yaml(__file__, 'fixtures/{}.yml'.format(plugin))
        else:
            data = load_from_yaml(__file__, 'fixtures/')

        if fname == 'test_matches':
            cases = []
            for entry in data:
                for match in entry.get('matches', []):
                    cases.append([entry['plugin'], match])

            metafunc.parametrize('plugin_name,match', cases)
        elif fname == 'test_js_matches':
            cases = []
            for entry in data:
                for match in entry.get('js_matches', []):
                    cases.append([entry['plugin'], match])

            metafunc.parametrize('plugin_name,match', cases)


    def test_matches(self, plugin_name, match, plugin_list):
        fake_har_entry = tree()
        if 'url' in match:
            method = Detector.get_version_from_url
            fake_har_entry['request']['url'] = match['url']
{'fraction_non_alphanumeric': 0.11130314552367784, 'fraction_numerical': 0.0, 'mean_word_length': 2.3534183082271145, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '336423', 'n_tokens_mistral': 824, 'n_tokens_neox': 809, 'n_words': 185}