<commit_before>import unittest
from os.path import abspath, dirname, normpath, join

from robot.utils.asserts import assert_equals, assert_true
from robot.new_running import TestSuite, TestSuiteBuilder


CURDIR = dirname(abspath(__file__))
DATADIR = normpath(join(CURDIR, '..', '..', 'atest', 'testdata', 'misc'))


class TestBuilding(unittest.TestCase):

    def _build(self, *paths):
        paths = [join(DATADIR, p) for p in paths]
        suite = TestSuiteBuilder().build(*paths)
        assert_true(isinstance(suite, TestSuite))
        assert_equals(suite.source, paths[0] if len(paths) == 1 else '')
        return suite

    def test_suite_data(self):
        suite = self._build('pass_and_fail.txt')
        assert_equals(suite.name, 'Pass And Fail')
        assert_equals(suite.doc, 'Some tests here')
        assert_equals(suite.metadata, {})

    def test_imports(self):
        imp = self._build('dummy_lib_test.txt').imports[0]
        assert_equals(imp.type, 'Library')
        assert_equals(imp.name, 'DummyLib')
        assert_equals(imp.args, ())

    def test_variables(self):
        variables = self._build('pass_and_fail.txt').variables
        assert_equals(variables[0].name, '${LEVEL1}')
        assert_equals(variables[0].value, 'INFO')
        assert_equals(variables[1].name, '${LEVEL2}')
        assert_equals(variables[1].value, 'DEBUG')

    def test_user_keywords(self):
        uk = self._build('pass_and_fail.txt').user_keywords[0]
        assert_equals(uk.name, 'My Keyword')
        assert_equals(uk.args, ('${who}',))

    def test_test_data(self):
        test = self._build('pass_and_fail.txt').tests[1]
        assert_equals(test.name, 'Fail')
        assert_equals(test.doc, 'FAIL Expected failure')
        assert_equals(list(test.tags), ['fail', 'force'])

    def test_test_keywords(self):
        kw = self._build('pass_and_fail.txt').tests[0].keywords[0]
        assert_equals(kw.name, 'My Keyword')
        assert_equals(kw.args, ('Pass',))
        assert_equals(kw.assign, ())
        assert_equals(kw.type, kw.KEYWORD_TYPE)

    def test_directory_suite(self):
        suite = self._build('suites')
        assert_equals(suite.name, 'Suites')
        assert_equals(suite.suites[1].name, 'Subsuites')<commit_msg>new run: test building assignement<commit_after>import unittest
from os.path import abspath, dirname, normpath, join

from robot.utils.asserts import assert_equals, assert_true
from robot.new_running import TestSuite, TestSuiteBuilder


CURDIR = dirname(abspath(__file__))
DATADIR = normpath(join(CURDIR, '..', '..', 'atest', 'testdata', 'misc'))


class TestBuilding(unittest.TestCase):

    def _build(self, *paths):
        paths = [join(DATADIR, p) for p in paths]
        suite = TestSuiteBuilder().build(*paths)
        assert_true(isinstance(suite, TestSuite))
        assert_equals(suite.source, paths[0] if len(paths) == 1 else '')
        return suite

    def test_suite_data(self):
        suite = self._build('pass_and_fail.txt')
        assert_equals(suite.name, 'Pass And Fail')
        assert_equals(suite.doc, 'Some tests here')
        assert_equals(suite.metadata, {})

    def test_imports(self):
        imp = self._build('dummy_lib_test.txt').imports[0]
        assert_equals(imp.type, 'Library')
        assert_equals(imp.name, 'DummyLib')
        assert_equals(imp.args, ())

    def test_variables(self):
        variables = self._build('pass_and_fail.txt').variables
        assert_equals(variables[0].name, '${LEVEL1}')
        assert_equals(variables[0].value, 'INFO')
        assert_equals(variables[1].name, '${LEVEL2}')
        assert_equals(variables[1].value, 'DEBUG')

    def test_user_keywords(self):
        uk = self._build('pass_and_fail.txt').user_keywords[0]
        assert_equals(uk.name, 'My Keyword')
        assert_equals(uk.args, ('${who}',))

    def test_test_data(self):
        test = self._build('pass_and_fail.txt').tests[1]
        assert_equals(test.name, 'Fail')
        assert_equals(test.doc, 'FAIL Expected failure')
        assert_equals(list(test.tags), ['fail', 'force'])

    def test_test_keywords(self):
        kw = self._build('pass_and_fail.txt').tests[0].keywords[0]
        assert_equals(kw.name, 'My Keyword')
        assert_equals(kw.args, ('Pass',))
        assert_equals(kw.assign, ())
        assert_equals(kw.type, kw.KEYWORD_TYPE)

    def test_assign(self):
        kw = self._build('unicode.txt').tests[1].keywords[0]
        assert_equals(kw.assign, ('${msg} =',))
        assert_equals(kw.name, 'Evaluate')
        assert_equals(kw.args, (r"u'Fran\\xe7ais'",))
        assert_equals(kw.type, kw.KEYWORD_TYPE)

    def test_directory_suite(self):
        suite = self._build('suites')
        assert_equals(suite.name, 'Suites')
        assert_equals(suite.suites[1].name, 'Subsuites')
{'fraction_non_alphanumeric': 0.14507772020725387, 'fraction_numerical': 0.006424870466321244, 'mean_word_length': 3.447926267281106, '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': '5505488', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1549, 'n_words': 267}