<commit_before>import pygrate.loader
import pygrate.pygration
import unittest
import os.path
import types


class TestPygration(pygrate.pygration.Pygration):
    def add( self ):
        pass


class PygrateTestCase(unittest.TestCase):
    def setUp( self ):
        test_dir = os.path.dirname( __file__ )
        self._loader = pygrate.loader.PygrationLoader( test_dir, 'r1' )
        syntax = pygrate.oracle_syntax.OracleSyntax()

    def testListModules( self ):
        modules = self._loader._list_modules()

        self.assertEqual( [ 'employee' ], modules )

    def testImportModules( self ):
        self._loader._import_modules()
        m = self._loader._modules
        self.assertEqual( 1, len(m) )
        self.assertEqual( types.ModuleType, type(m[0]) )

    def testLoad( self ):
        self._loader.load()
        p = self._loader.pygrations()

        self.assertEqual( 1, len(p) )
        self.assertTrue( isinstance( p[0], pygrate.pygration.Pygration ) )

    def testPygrationSubclass( self ):
        tp = TestPygration
        bp = pygrate.pygration.Pygration
        dict = {}

        self.assertTrue( self._loader._pygration_subclass( tp ) )
        self.assertFalse( self._loader._pygration_subclass( bp ) )
        self.assertFalse( self._loader._pygration_subclass( dict ) )


class VersionTestCase(unittest.TestCase):
    """Tests for the pygration Version class."""

    def test_underscore_is_pygration(self):
        """Check that v0_0_0 is reported as a pygration version."""
        v = pygrate.loader.Version("v0_0_0")
        self.assertTrue( v.is_pygration() )

    def test_dash_is_pygration(self):
        """Check that v0-0-0 is reported as a pygration version."""
        v = pygrate.loader.Version("v0-0-0")
        self.assertTrue( v.is_pygration() )

    def test_dot_is_pygration(self):
        """Check that v0.0.0 is reported as a pygration version."""
        v = pygrate.loader.Version("v0.0.0")
        self.assertTrue( v.is_pygration() )

    def test_asdf_is_not_pygration(self):
        """Assert that asdf is reported as not a pygration version."""
        v = pygrate.loader.Version("asdf")
        self.assertFalse( v.is_pygration() )

    def test_underscore_comparison(self):
        v1 = pygrate.loader.Version("v0_1_2")
        v2 = pygrate.loader.Version("v0_2_2")
        self.assertTrue( v1.compare(v2) < 0 )
        self.assertTrue( v2.compare(v1) > 0 )<commit_msg>new tests for different version comparisons<commit_after>import pygrate.loader
import pygrate.pygration
import unittest
import os.path
import types


class TestPygration(pygrate.pygration.Pygration):
    def add( self ):
        pass


class PygrateTestCase(unittest.TestCase):
    def setUp( self ):
        test_dir = os.path.dirname( __file__ )
        self._loader = pygrate.loader.PygrationLoader( test_dir, 'r1' )
        syntax = pygrate.oracle_syntax.OracleSyntax()

    def testListModules( self ):
        modules = self._loader._list_modules()

        self.assertEqual( [ 'employee' ], modules )

    def testImportModules( self ):
        self._loader._import_modules()
        m = self._loader._modules
        self.assertEqual( 1, len(m) )
        self.assertEqual( types.ModuleType, type(m[0]) )

    def testLoad( self ):
        self._loader.load()
        p = self._loader.pygrations()

        self.assertEqual( 1, len(p) )
        self.assertTrue( isinstance( p[0], pygrate.pygration.Pygration ) )

    def testPygrationSubclass( self ):
        tp = TestPygration
        bp = pygrate.pygration.Pygration
        dict = {}

        self.assertTrue( self._loader._pygration_subclass( tp ) )
        self.assertFalse( self._loader._pygration_subclass( bp ) )
        self.assertFalse( self._loader._pygration_subclass( dict ) )


class VersionTestCase(unittest.TestCase):
    """Tests for the pygration Version class."""

    def test_underscore_is_pygration(self):
        """Check that v0_0_0 is reported as a pygration version."""
        v = pygrate.loader.Version("v0_0_0")
        self.assertTrue( v.is_pygration() )

    def test_dash_is_pygration(self):
        """Check that v0-0-0 is reported as a pygration version."""
        v = pygrate.loader.Version("v0-0-0")
        self.assertTrue( v.is_pygration() )

    def test_dot_is_pygration(self):
        """Check that v0.0.0 is reported as a pygration version."""
        v = pygrate.loader.Version("v0.0.0")
        self.assertTrue( v.is_pygration() )

    def test_asdf_is_not_pygration(self):
        """Assert that asdf is reported as not a pygration version."""
        v = pygrate.loader.Version("asdf")
        self.assertFalse( v.is_pygration() )

    def test_extended_version(self):
        """Test that a version with a sub-build number is compared later"""
        v1 = pygrate.loader.Version("v1")
        v2 = pygrate.loader.Version("v1-2")
        self.assertTrue( v1.compare(v2) < 0 )
        self.assertTrue( v2.compare(v1) > 0 )

    def test_numeric_compare(self):
        """Test that a numeric version is compared as a number."""
        v1 = pygrate.loader.Version("v1-2")
        v2 = pygrate.loader.Version("v1-12")
        self.assertTrue( v1.compare(v2) < 0 )
        self.assertTrue( v2.compare(v1) > 0 )

    def test_underscore_comparison(self):
        v1 = pygrate.loader.Version("v0_1_2")
        v2 = pygrate.loader.Version("v0_2_2")
        self.assertTrue( v1.compare(v2) < 0 )
        self.assertTrue( v2.compare(v1) > 0 )
{'fraction_non_alphanumeric': 0.11752878815573022, 'fraction_numerical': 0.017912630232133065, 'mean_word_length': 2.763411279229711, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '767146', 'n_tokens_mistral': 1837, 'n_tokens_neox': 1796, 'n_words': 372}