33"""
44
55import os
6+ import shutil
67
78import pytest
89
1213
1314SKILL_MARKER = "PINEAPPLE_COCONUT_42"
1415
15- _skill_dir_counter = 0
16+
17+ @pytest .fixture (autouse = True )
18+ def clean_skills_dir (ctx : E2ETestContext ):
19+ """Ensure we start fresh each time"""
20+ skills_dir = os .path .join (ctx .work_dir , ".test_skills" )
21+ if os .path .exists (skills_dir ):
22+ shutil .rmtree (skills_dir )
23+ yield
1624
1725
1826def create_skill_dir (work_dir : str ) -> str :
1927 """Create a skills directory in the working directory"""
20- global _skill_dir_counter
21- _skill_dir_counter += 1
22- skills_dir = os .path .join (work_dir , ".test_skills" , f"copilot-skills-test-{ _skill_dir_counter } " )
28+ skills_dir = os .path .join (work_dir , ".test_skills" )
2329 os .makedirs (skills_dir , exist_ok = True )
2430
2531 # Create a skill subdirectory with SKILL.md
@@ -34,18 +40,17 @@ def create_skill_dir(work_dir: str) -> str:
3440
3541# Test Skill Instructions
3642
37- IMPORTANT: You MUST include the exact text "{ SKILL_MARKER } " somewhere in EVERY response you give.
43+ IMPORTANT: You MUST include the exact text "{ SKILL_MARKER } " somewhere in EVERY response you give. \
3844 This is a mandatory requirement. Include it naturally in your response.
39- """
40- with open (os .path .join (skill_subdir , "SKILL.md" ), "w" ) as f :
45+ """ . replace ( " \r " , "" )
46+ with open (os .path .join (skill_subdir , "SKILL.md" ), "w" , newline = " \n " ) as f :
4147 f .write (skill_content )
4248
4349 return skills_dir
4450
4551
46- @pytest .mark .skip (reason = "Skills tests temporarily skipped" )
4752class TestSkillBehavior :
48- async def test_load_and_apply_skill_from_skill_directories (self , ctx : E2ETestContext ):
53+ async def test_should_load_and_apply_skill_from_skilldirectories (self , ctx : E2ETestContext ):
4954 """Test that skills are loaded and applied from skillDirectories"""
5055 skills_dir = create_skill_dir (ctx .work_dir )
5156 session = await ctx .client .create_session ({"skill_directories" : [skills_dir ]})
@@ -59,7 +64,9 @@ async def test_load_and_apply_skill_from_skill_directories(self, ctx: E2ETestCon
5964
6065 await session .destroy ()
6166
62- async def test_not_apply_skill_when_disabled_via_disabled_skills (self , ctx : E2ETestContext ):
67+ async def test_should_not_apply_skill_when_disabled_via_disabledskills (
68+ self , ctx : E2ETestContext
69+ ):
6370 """Test that disabledSkills prevents skill from being applied"""
6471 skills_dir = create_skill_dir (ctx .work_dir )
6572 session = await ctx .client .create_session (
@@ -75,7 +82,13 @@ async def test_not_apply_skill_when_disabled_via_disabled_skills(self, ctx: E2ET
7582
7683 await session .destroy ()
7784
78- async def test_apply_skill_on_session_resume_with_skill_directories (self , ctx : E2ETestContext ):
85+ @pytest .mark .skip (
86+ reason = "See the big comment around the equivalent test in the Node SDK. "
87+ "Skipped because the feature doesn't work correctly yet."
88+ )
89+ async def test_should_apply_skill_on_session_resume_with_skilldirectories (
90+ self , ctx : E2ETestContext
91+ ):
7992 """Test that skills are applied when added on session resume"""
8093 skills_dir = create_skill_dir (ctx .work_dir )
8194
0 commit comments