<commit_before>import unittest
import sys
import os
from types import *

from robot.utils.asserts import *
from robot import utils
if utils.is_jython:
    import JavaExceptions

from robot.utils.misc import *



class TestMiscUtils(unittest.TestCase):
    
    def test_seq2str(self):
        for exp, seq in [ ( "", () ),
                          ( "'One'", ("One",) ),
                          ( "'1' and '2'", ("1","2") ),
                          ( "'1', '2', '3', 'f o u r', 'fi ve' and '6'",
                            ("1","2","3","f o u r","fi ve","6") ) ]:
            assert_equals(exp, seq2str(seq))

            
    def test_get_link_path(self):
        if os.sep == '/':
            inputs = [
                ( '/tmp/', '/tmp/bar.txt', 'bar.txt' ),
                ( '/tmp', '/tmp/x/bar.txt', 'x/bar.txt' ),
                ( '/tmp/', '/tmp/x/y/bar.txt', 'x/y/bar.txt' ),
                ( '/tmp/', '/tmp/x/y/z/bar.txt', 'x/y/z/bar.txt' ),
                ( '/tmp', '/x/y/z/bar.txt', '../x/y/z/bar.txt' ),
                ( '/tmp/', '/x/y/z/bar.txt', '../x/y/z/bar.txt' ),
                ( '/tmp', '/x/bar.txt', '../x/bar.txt' ),
                ( '/tmp', '/x/y/z/bar.txt', '../x/y/z/bar.txt' ),
                ( '/', '/x/bar.txt', 'x/bar.txt' ) ]
        else:
            inputs = [
                ( 'c:\\temp\\', 'c:\\temp\\bar.txt', 'bar.txt' ),
                ( 'c:\\temp', 'c:\\temp\\x\\bar.txt', 'x/bar.txt' ),
                ( 'c:\\temp\\', 'c:\\temp\\x\\y\\bar.txt', 'x/y/bar.txt' ),
                ( 'c:\\temp', 'c:\\temp\\x\\y\\z\\bar.txt',
                  'x/y/z/bar.txt' ),
                ( 'c:\\temp\\', 'c:\\x\\y\\bar.txt', '../x/y/bar.txt' ),
                ( 'c:\\temp', 'c:\\x\\y\\bar.txt', '../x/y/bar.txt' ),  
                ( 'c:\\temp', 'c:\\x\\bar.txt', '../x/bar.txt' ),
                ( 'c:\\temp', 'c:\\x\\y\\z\\bar.txt', '../x/y/z/bar.txt' ),
                ( 'c:\\temp\\', 'r:\\x\\y\\bar.txt', 'file:///r:/x/y/bar.txt' ),
                ( 'c:\\', 'c:\\x\\bar.txt', 'x/bar.txt' ) ]

        for basedir, target, expected in inputs:
            assert_equal(get_link_path(target, basedir), expected,
                         '%s -> %s' % (target, basedir))
                  
    def test_printable_name_from_path(self):
        paths_and_names = [ ('tests.html', 'Tests'),
                            ('my tests.html', 'My Tests'),
                            ('your_tests', 'Your Tests'),
                            ('TESTS.HTML', 'TESTS'),
                            ('camelCaseTests', 'Camel Case Tests'),
                            ('MoreCAMELCase', 'More CAMEL Case'),
                            ('some_set_of_tests', 'Some Set Of Tests'),
                            ('1_more test_set here ', '1 More Test Set Here') ]
        if os.sep == '/':<commit_msg>Added error message if needed C:\temp is not available at Windows.<commit_after>import unittest
import sys
import os
from types import *

from robot.utils.asserts import *
from robot import utils
if utils.is_jython:
    import JavaExceptions

from robot.utils.misc import *



class TestMiscUtils(unittest.TestCase):
    
    def test_seq2str(self):
        for exp, seq in [ ( "", () ),
                          ( "'One'", ("One",) ),
                          ( "'1' and '2'", ("1","2") ),
                          ( "'1', '2', '3', 'f o u r', 'fi ve' and '6'",
                            ("1","2","3","f o u r","fi ve","6") ) ]:
            assert_equals(exp, seq2str(seq))

            
    def test_get_link_path(self):
        if os.sep == '/':
            inputs = [
                ( '/tmp/', '/tmp/bar.txt', 'bar.txt' ),
                ( '/tmp', '/tmp/x/bar.txt', 'x/bar.txt' ),
                ( '/tmp/', '/tmp/x/y/bar.txt', 'x/y/bar.txt' ),
                ( '/tmp/', '/tmp/x/y/z/bar.txt', 'x/y/z/bar.txt' ),
                ( '/tmp', '/x/y/z/bar.txt', '../x/y/z/bar.txt' ),
                ( '/tmp/', '/x/y/z/bar.txt', '../x/y/z/bar.txt' ),
                ( '/tmp', '/x/bar.txt', '../x/bar.txt' ),
                ( '/tmp', '/x/y/z/bar.txt', '../x/y/z/bar.txt' ),
                ( '/', '/x/bar.txt', 'x/bar.txt' ) ]
        else:
            assert os.path.isdir('c:\\temp\\'), "This test requires c:\\temp to exist"
            inputs = [
                ( 'c:\\temp\\', 'c:\\temp\\bar.txt', 'bar.txt' ),
                ( 'c:\\temp', 'c:\\temp\\x\\bar.txt', 'x/bar.txt' ),
                ( 'c:\\temp\\', 'c:\\temp\\x\\y\\bar.txt', 'x/y/bar.txt' ),
                ( 'c:\\temp', 'c:\\temp\\x\\y\\z\\bar.txt',
                  'x/y/z/bar.txt' ),
                ( 'c:\\temp\\', 'c:\\x\\y\\bar.txt', '../x/y/bar.txt' ),
                ( 'c:\\temp', 'c:\\x\\y\\bar.txt', '../x/y/bar.txt' ),  
                ( 'c:\\temp', 'c:\\x\\bar.txt', '../x/bar.txt' ),
                ( 'c:\\temp', 'c:\\x\\y\\z\\bar.txt', '../x/y/z/bar.txt' ),
                ( 'c:\\temp\\', 'r:\\x\\y\\bar.txt', 'file:///r:/x/y/bar.txt' ),
                ( 'c:\\', 'c:\\x\\bar.txt', 'x/bar.txt' ) ]

        for basedir, target, expected in inputs:
            assert_equal(get_link_path(target, basedir), expected,
                         '%s -> %s' % (target, basedir))
                  
    def test_printable_name_from_path(self):
        paths_and_names = [ ('tests.html', 'Tests'),
                            ('my tests.html', 'My Tests'),
                            ('your_tests', 'Your Tests'),
                            ('TESTS.HTML', 'TESTS'),
                            ('camelCaseTests', 'Camel Case Tests'),
                            ('MoreCAMELCase', 'More CAMEL Case'),
                            ('some_set_of_tests', 'Some Set Of Tests'),
                            ('1_more test_set here ', '1 More Test Set Here') ]
        if os.sep == '/':
{'fraction_non_alphanumeric': 0.23955816361753537, 'fraction_numerical': 0.005522954780807732, 'mean_word_length': 1.2093023255813953, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1172884', 'n_tokens_mistral': 2060, 'n_tokens_neox': 2009, 'n_words': 354}