-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test to check that sector{,imp}list.txt are deduplicated
- Loading branch information
1 parent
23c06ab
commit 01b383e
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Created on Jan 12, 2025 | ||
@author: CyberiaResurrection | ||
""" | ||
import codecs | ||
import os | ||
import tempfile | ||
|
||
from Tests.baseTest import baseTest | ||
from pytest_console_scripts import ScriptRunner | ||
|
||
|
||
class testUniqueSectors(baseTest): | ||
|
||
def testSectorListIsUnique(self): | ||
fullpath = self.unpack_filename('../PyRoute/unique_sectors.py') | ||
|
||
cases = [ | ||
("sectorlist.txt", "../sectorlist.txt"), | ||
("sectorimplist.txt", "../sectorimplist.txt") | ||
] | ||
|
||
for filename, fullname in cases: | ||
with self.subTest(filename): | ||
outfile = tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") | ||
srcfile = os.path.abspath(fullname) | ||
|
||
cwd = os.getcwd() | ||
runner = ScriptRunner(launch_mode="subprocess", rootdir=cwd, print_result=False) | ||
|
||
foo = runner.run([fullpath, "--infile", srcfile, "--outfile", outfile.name]) | ||
self.assertEqual(0, foo.returncode, "unique_sectors did not complete successfully: " + foo.stderr) | ||
|
||
inlines = [] | ||
with codecs.open(srcfile, 'r', 'utf-8') as infile: | ||
inlines = [line for line in infile] | ||
|
||
outlines = [] | ||
with codecs.open(outfile.name, 'r', 'utf-8') as outfile: | ||
outlines = [line for line in outfile] | ||
outfile.close() | ||
|
||
self.assertEqual(len(outlines), len(inlines), filename + " has at least one duplicate") | ||
|