From dd1dbfbfdd1d66ee4c62487a6394fa5d10f2e443 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Thu, 28 Jan 2021 12:23:13 -0800 Subject: [PATCH] Rework copyfile and skip based on feedback from windows test --- tests/test_octodns_source_axfr.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_octodns_source_axfr.py b/tests/test_octodns_source_axfr.py index f732060..e0871ee 100644 --- a/tests/test_octodns_source_axfr.py +++ b/tests/test_octodns_source_axfr.py @@ -9,6 +9,7 @@ import dns.zone from dns.exception import DNSException from mock import patch +from os.path import exists from shutil import copyfile from six import text_type from unittest import TestCase @@ -55,12 +56,19 @@ class TestZoneFileSource(TestCase): self.assertEquals(1, len(valid.records)) def test_zonefiles_without_extension(self): - try: - copyfile('./tests/zones/unit.tests.tst', - './tests/zones/unit.tests.') - except: + # Windows doesn't let files end with a `.` so we add a .tst to them in + # the repo and then try and create the `.` version we need for the + # default case (no extension.) + copyfile('./tests/zones/unit.tests.tst', './tests/zones/unit.tests.') + # Unfortunately copyfile silently works and create the file without + # the `.` so we have to check to see if it did that + if exists('./tests/zones/unit.tests'): + # It did so we need to skip this test, that means windows won't + # have full code coverage, but skipping the test is going out of + # our way enough for a os-specific/oddball case. self.skipTest('Unable to create unit.tests. (ending with .) so ' 'skipping default filename testing.') + source = ZoneFileSource('test', './tests/zones') # Load zonefiles without a specified file extension valid = Zone('unit.tests.', [])