Commit c7505221 authored by Mischa Krüger's avatar Mischa Krüger

ExecutableRequirement: Add .bat and .cmd tests

... under Windows.

Closes coala/package_manager#94
parent b1a49fc4
import os
from platform import system
from tempfile import TemporaryDirectory
import unittest
from dependency_management.requirements.ExecutableRequirement import (
......@@ -12,3 +15,24 @@ class ExecutableRequirementTestCase(unittest.TestCase):
def test_not_installed_requirement(self):
@unittest.skipIf(system() != 'Windows', 'Windows-specific test.')
def test_installed_batch_requirements(self):
for batchfile in ('some_executable.bat', 'some_executable.cmd'):
uut = ExecutableRequirement(batchfile)
with TemporaryDirectory() as tmp:
# Create batch file.
open(os.path.join(tmp, batchfile), 'w').close()
# Add batch to path. sys.path doesn't work, changes in this
# list aren't picked up.
old_path = os.environ['PATH']
os.environ['PATH'] = tmp + ';' + old_path
# Remove again from path.
os.environ['PATH'] = old_path
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment