Skip to content

Commit

Permalink
Implemented a cleaner solution for making the test's year dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneallcroft committed Nov 17, 2017
1 parent 9e6e619 commit 9cbfb6e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/test_ebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from time import gmtime, strftime
import re

from superflore.generators.ebuild.ebuild import Ebuild
from superflore.generators.ebuild.ebuild import ebuild_keyword
Expand All @@ -34,13 +35,9 @@ def test_simple(self):
ebuild = self.get_ebuild()
ebuild.add_run_depend('p2os_driver')
got_text = ebuild.get_ebuild_text('Open Source Robotics Foundation', 'BSD')
with open('tests/ebuild/simple_expected.ebuild', 'r+') as expect_file:
expect_file.read(16)
fileUpdateStr = "# Copyright " + strftime("%Y", gmtime())
fileUpdateStr += expect_file.read()
expect_file.write(fileUpdateStr)
expect_file.flush()
correct_text = fileUpdateStr;
with open('tests/ebuild/simple_expected.ebuild', 'r') as expect_file:
s = expect_file.read()
correct_text = re.sub('Copyright 2017', 'Copyright ' + strftime("%Y", gmtime()), s)
self.assertEqual(got_text, correct_text)

def test_bad_external_build_depend(self):
Expand Down

0 comments on commit 9cbfb6e

Please # to comment.