<commit_before>from __future__ import absolute_import

import json
import unittest

from six import StringIO

from cwltool.main import main

from .util import get_data, needs_docker


class TestOverride(unittest.TestCase):
    @needs_docker
    def test_overrides(self):
        sio = StringIO()

        self.assertEquals(main([get_data('tests/override/echo.cwl'),
                                get_data('tests/override/echo-job.yml')],
                               stdout=sio), 0)
        self.assertEquals({"out": "zing hello1\n"}, json.loads(sio.getvalue()))

        sio = StringIO()
        self.assertEquals(main(["--overrides", get_data('tests/override/ov.yml'),
                                get_data('tests/override/echo.cwl'),
                                get_data('tests/override/echo-job.yml')],
                               stdout=sio), 0)
        self.assertEquals({"out": "zing hello2\n"}, json.loads(sio.getvalue()))

        sio = StringIO()
        self.assertEquals(main([get_data('tests/override/echo.cwl'),
                                get_data('tests/override/echo-job-ov.yml')],
                               stdout=sio), 0)
        self.assertEquals({"out": "zing hello3\n"}, json.loads(sio.getvalue()))

        sio = StringIO()
        self.assertEquals(main([get_data('tests/override/echo-job-ov2.yml')],
                               stdout=sio), 0)
        self.assertEquals({"out": "zing hello4\n"}, json.loads(sio.getvalue()))


        sio = StringIO()
        self.assertEquals(main(["--overrides", get_data('tests/override/ov.yml'),
                                get_data('tests/override/echo-wf.cwl'),
                                get_data('tests/override/echo-job.yml')],
                               stdout=sio), 0)
        self.assertEquals({"out": "zing hello2\n"}, json.loads(sio.getvalue()))

        sio = StringIO()
        self.assertEquals(main(["--overrides", get_data('tests/override/ov2.yml'),
                                get_data('tests/override/echo-wf.cwl'),
                                get_data('tests/override/echo-job.yml')],
                               stdout=sio), 0)
        self.assertEquals({"out": "zing hello5\n"}, json.loads(sio.getvalue()))

        sio = StringIO()
        self.assertEquals(main(["--overrides", get_data('tests/override/ov3.yml'),
                                get_data('tests/override/echo-wf.cwl'),
                                get_data('tests/override/echo-job.yml')],
                               stdout=sio), 0)
        self.assertEquals({"out": "zing hello6\n"}, json.loads(sio.getvalue()))<commit_msg>maintenance: remove unittest from test_override<commit_after>import json

from six import StringIO

import pytest

from cwltool.main import main

from .util import get_data, needs_docker

override_parameters = [
    ([get_data('tests/override/echo.cwl'),
      get_data('tests/override/echo-job.yml')],
     {"out": "zing hello1\n"}
     ),
    (["--overrides",
      get_data('tests/override/ov.yml'),
      get_data('tests/override/echo.cwl'),
      get_data('tests/override/echo-job.yml')],
     {"out": "zing hello2\n"}
     ),
    ([get_data('tests/override/echo.cwl'),
      get_data('tests/override/echo-job-ov.yml')],
     {"out": "zing hello3\n"}
     ),
    ([get_data('tests/override/echo-job-ov2.yml')],
     {"out": "zing hello4\n"}
     ),
    (["--overrides",
      get_data('tests/override/ov.yml'),
      get_data('tests/override/echo-wf.cwl'),
      get_data('tests/override/echo-job.yml')],
     {"out": "zing hello2\n"}
     ),
    (["--overrides",
      get_data('tests/override/ov2.yml'),
      get_data('tests/override/echo-wf.cwl'),
      get_data('tests/override/echo-job.yml')],
     {"out": "zing hello5\n"}
     ),
    (["--overrides",
      get_data('tests/override/ov3.yml'),
      get_data('tests/override/echo-wf.cwl'),
      get_data('tests/override/echo-job.yml')],
     {"out": "zing hello6\n"}
     ),
]

@needs_docker
@pytest.mark.parametrize('parameters,result', override_parameters)
def test_overrides(parameters, result):
    sio = StringIO()

    assert main(parameters, stdout=sio) == 0
    assert json.loads(sio.getvalue()) == result
{'fraction_non_alphanumeric': 0.1644486692015209, 'fraction_numerical': 0.006653992395437262, 'mean_word_length': 2.1838124054462935, 'pattern_counts': {'":': 14, '<': 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': '6474962', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1307, 'n_words': 181}