Пример #1
0
    def test_extra_year(self):
        with self.assertRaises(ValueError) as context:
            sort_copyrights([
                "Copyright © 2015, 2016, 2018 John Doe <foo@bar>",
                "Copyright © 2016 John Doe <foo@bar>",
                "Copyright © 2016, 2017, 2019 John Doe <foo@bar>"
            ])

        self.assertIn('First copyright found for <foo@bar> is missing years {2017, 2019}', context.exception.args[0])
Пример #2
0
    def test_extra_year(self):
        with self.assertRaises(ValueError) as context:
            sort_copyrights([
                "Copyright © 2015, 2016, 2018 John Doe <foo@bar>",
                "Copyright © 2016 John Doe <foo@bar>",
                "Copyright © 2016, 2017, 2019 John Doe <foo@bar>"
            ])

        self.assertIn('First copyright found for <foo@bar> is missing years {2017, 2019}', context.exception.args[0])
Пример #3
0
    def test_extra_year2(self):
        with self.assertRaises(ValueError) as context:
            sort_copyrights([
                "Copyright © 2016 John Doe <foo@bar>",
                # After this entry the set needs to get updated, otherwise
                # 2018 will get lost
                "Copyright © 2016, 2018 John Doe <foo@bar>",
                "Copyright © 2016, 2020 John Doe <foo@bar>"
            ])

        self.assertIn(
            'First copyright found for <foo@bar> is missing years {2020}',
            context.exception.args[0])
Пример #4
0
 def test_pick_longer(self):
     self.assertEqual(sort_copyrights([
         "Copyright © 2015 John Doe <foo@bar>",
         "Copyright © 2015, 2016, 2018 John Doe <foo@bar>"
     ]), [
         "Copyright © 2015, 2016, 2018 John Doe <foo@bar>"
     ])
Пример #5
0
 def test_pick_longer(self):
     self.assertEqual(sort_copyrights([
         "Copyright © 2015 John Doe <foo@bar>",
         "Copyright © 2015, 2016, 2018 John Doe <foo@bar>"
     ]), [
         "Copyright © 2015, 2016, 2018 John Doe <foo@bar>"
     ])
Пример #6
0
 def test_pick_earlier(self):
     self.assertEqual(sort_copyrights([
         "Copyright © 2015, 2016, 2018 John Doe <foo@bar>",
         "Copyright © 2018 John Doe <foo@bar>",
         "Copyright © 1997, 2003 Boo Bee <bar@bar>",
         "Copyright © 2016 John Doe <foo@bar>"
     ]), [
         "Copyright © 1997, 2003 Boo Bee <bar@bar>",
         "Copyright © 2015, 2016, 2018 John Doe <foo@bar>"
     ])
Пример #7
0
 def test_sort(self):
     self.assertEqual(sort_copyrights([
         "Copyright © 2015, 2016 John Doe <foo@bar>",
         "Copyright © 1997, 2003 Boo Bee <bar@bar>",
         "Copyright © 2018 Ho <hu@he>"
     ]), [
         "Copyright © 1997, 2003 Boo Bee <bar@bar>",
         "Copyright © 2015, 2016 John Doe <foo@bar>",
         "Copyright © 2018 Ho <hu@he>"
     ])
Пример #8
0
 def test_pick_earlier(self):
     self.assertEqual(sort_copyrights([
         "Copyright © 2015, 2016, 2018 John Doe <foo@bar>",
         "Copyright © 2018 John Doe <foo@bar>",
         "Copyright © 1997, 2003 Boo Bee <bar@bar>",
         "Copyright © 2016 John Doe <foo@bar>"
     ]), [
         "Copyright © 1997, 2003 Boo Bee <bar@bar>",
         "Copyright © 2015, 2016, 2018 John Doe <foo@bar>"
     ])
Пример #9
0
 def test_sort(self):
     self.assertEqual(sort_copyrights([
         "Copyright © 2015, 2016 John Doe <foo@bar>",
         "Copyright © 1997, 2003 Boo Bee <bar@bar>",
         "Copyright © 2018 Ho <hu@he>"
     ]), [
         "Copyright © 1997, 2003 Boo Bee <bar@bar>",
         "Copyright © 2015, 2016 John Doe <foo@bar>",
         "Copyright © 2018 Ho <hu@he>"
     ])