@@ -201,30 +201,30 @@ def sample_needlinks():
201201 NeedLink (
202202 file = Path ("src/implementation1.py" ),
203203 line = 3 ,
204- tag = "# req-Id:" ,
204+ tag = "#" + " req-Id:" ,
205205 need = "TREQ_ID_1" ,
206- full_line = "# req-Id: TREQ_ID_1" ,
206+ full_line = "#" + " req-Id: TREQ_ID_1" ,
207207 ),
208208 NeedLink (
209209 file = Path ("src/implementation2.py" ),
210210 line = 3 ,
211- tag = "# req-Id:" ,
211+ tag = "#" + " req-Id:" ,
212212 need = "TREQ_ID_1" ,
213- full_line = "# req-Id: TREQ_ID_1" ,
213+ full_line = "#" + " req-Id: TREQ_ID_1" ,
214214 ),
215215 NeedLink (
216216 file = Path ("src/implementation1.py" ),
217217 line = 9 ,
218- tag = "# req-Id:" ,
218+ tag = "#" + " req-Id:" ,
219219 need = "TREQ_ID_2" ,
220- full_line = "# req-Id: TREQ_ID_2" ,
220+ full_line = "#" + " req-Id: TREQ_ID_2" ,
221221 ),
222222 NeedLink (
223223 file = Path ("src/bad_implementation.py" ),
224224 line = 2 ,
225- tag = "# req-Id:" ,
225+ tag = "#" + " req-Id:" ,
226226 need = "TREQ_ID_200" ,
227- full_line = "# req-Id: TREQ_ID_200" ,
227+ full_line = "#" + " req-Id: TREQ_ID_200" ,
228228 ),
229229 ]
230230
@@ -452,9 +452,9 @@ def test_get_github_link_with_real_repo(git_repo):
452452 needlink = NeedLink (
453453 file = Path ("src/test.py" ),
454454 line = 42 ,
455- tag = "# req-Id:" ,
455+ tag = "#" + " req-Id:" ,
456456 need = "REQ_001" ,
457- full_line = "# req-Id: REQ_001" ,
457+ full_line = "#" + " req-Id: REQ_001" ,
458458 )
459459
460460 result = get_github_link (git_repo , needlink )
@@ -502,9 +502,9 @@ def test_cache_file_with_encoded_comments(temp_dir):
502502 NeedLink (
503503 file = Path ("src/test.py" ),
504504 line = 1 ,
505- tag = "# req-Id:" ,
505+ tag = "#" + " req-Id:" ,
506506 need = "TEST_001" ,
507- full_line = "# req-Id: TEST_001" ,
507+ full_line = "#" + " req-Id: TEST_001" ,
508508 )
509509 ]
510510
@@ -514,14 +514,14 @@ def test_cache_file_with_encoded_comments(temp_dir):
514514 # Check the raw JSON to verify encoding
515515 with open (cache_file , "r" ) as f :
516516 raw_content = f .read ()
517- assert "# req-Id:" in raw_content # Should be encoded
517+ assert "#" + " req-Id:" in raw_content # Should be encoded
518518 assert "#-----req-Id:" not in raw_content # Original should not be present
519519
520520 # Load and verify decoding
521521 loaded_links = load_source_code_links_json (cache_file )
522522 assert len (loaded_links ) == 1
523- assert loaded_links [0 ].tag == "# req-Id:" # Should be decoded back
524- assert loaded_links [0 ].full_line == "# req-Id: TEST_001"
523+ assert loaded_links [0 ].tag == "#" + " req-Id:" # Should be decoded back
524+ assert loaded_links [0 ].full_line == "#" + " req-Id: TEST_001"
525525
526526
527527# Integration tests
@@ -559,24 +559,31 @@ def test_end_to_end_with_real_files(temp_dir, git_repo):
559559 src_dir = git_repo / "src"
560560 src_dir .mkdir ()
561561
562- (src_dir / "implementation1.py" ).write_text ("""
562+ (src_dir / "implementation1.py" ).write_text (
563+ """
563564# Some implementation
564- # req-Id: TREQ_ID_1
565+ #"""
566+ + """ req-Id: TREQ_ID_1
565567def function1():
566568 pass
567569
568570# Another function
569- # req-Id: TREQ_ID_2
571+ #"""
572+ + """ req-Id: TREQ_ID_2
570573def function2():
571574 pass
572- """ )
575+ """
576+ )
573577
574- (src_dir / "implementation2.py" ).write_text ("""
578+ (src_dir / "implementation2.py" ).write_text (
579+ """
575580# Another implementation
576- # req-Id: TREQ_ID_1
581+ #"""
582+ + """ req-Id: TREQ_ID_1
577583def another_function():
578584 pass
579- """ )
585+ """
586+ )
580587
581588 # Commit the changes
582589 subprocess .run (["git" , "add" , "." ], cwd = git_repo , check = True )
@@ -589,23 +596,23 @@ def another_function():
589596 NeedLink (
590597 file = Path ("src/implementation1.py" ),
591598 line = 3 ,
592- tag = "# req-Id:" ,
599+ tag = "#" + " req-Id:" ,
593600 need = "TREQ_ID_1" ,
594- full_line = "# req-Id: TREQ_ID_1" ,
601+ full_line = "#" + " req-Id: TREQ_ID_1" ,
595602 ),
596603 NeedLink (
597604 file = Path ("src/implementation1.py" ),
598605 line = 8 ,
599- tag = "# req-Id:" ,
606+ tag = "#" + " req-Id:" ,
600607 need = "TREQ_ID_2" ,
601- full_line = "# req-Id: TREQ_ID_2" ,
608+ full_line = "#" + " req-Id: TREQ_ID_2" ,
602609 ),
603610 NeedLink (
604611 file = Path ("src/implementation2.py" ),
605612 line = 3 ,
606- tag = "# req-Id:" ,
613+ tag = "#" + " req-Id:" ,
607614 need = "TREQ_ID_1" ,
608- full_line = "# req-Id: TREQ_ID_1" ,
615+ full_line = "#" + " req-Id: TREQ_ID_1" ,
609616 ),
610617 ]
611618
@@ -652,9 +659,9 @@ def test_multiple_commits_hash_consistency(git_repo):
652659 needlink = NeedLink (
653660 file = Path ("new_file.py" ),
654661 line = 1 ,
655- tag = "# req-Id:" ,
662+ tag = "#" + " req-Id:" ,
656663 need = "TEST_001" ,
657- full_line = "# req-Id: TEST_001 " ,
664+ full_line = "#" + " req-Id: TREQ_ID_1 " ,
658665 )
659666
660667 os .chdir (Path (git_repo ).absolute ())
0 commit comments