11import unittest
22import json
3- import os
43from pathlib import Path
54import shutil
65import pygit2
76import OMPython
87
9- from ompackagemanager .updateinfo import new_libentry , getgitrepo
8+ from ompackagemanager .updateinfo import new_libentry
109
1110
1211class TestNewLibentry (unittest .TestCase ):
1312 @classmethod
1413 def setUpClass (cls ):
1514 """Clone git repositories, start OMC session."""
1615
17- def checkout_repo (github_repo : str , refname : str ) -> str :
16+ def checkout_repo (github_repo : str , refname : str ) -> Path :
1817 """Clone and checkout a git repository from GitHub"""
1918 giturl = "https://github.com/%s.git" % github_repo
20- repopath = os . path . join ( cls .cache_dir , github_repo .split ("/" )[- 1 ])
19+ repopath = cls .cache_dir . joinpath ( github_repo .split ("/" )[- 1 ])
2120
22- if not os . path . exists ( repopath ):
21+ if not repopath . is_dir ( ):
2322 pygit2 .clone_repository (giturl , repopath )
2423 gitrepo = pygit2 .Repository (repopath )
2524
@@ -32,10 +31,10 @@ def checkout_repo(github_repo: str, refname: str) -> str:
3231 gitrepo .get (refname ),
3332 strategy = pygit2 .GIT_CHECKOUT_FORCE | pygit2 .GIT_CHECKOUT_RECREATE_MISSING )
3433
35- return os . path . normpath ( os .path . join ( gitrepo . path , os . pardir ) )
34+ return Path ( gitrepo .path ). joinpath (). parent . resolve ( )
3635
37- cls .cache_dir = os . path . join ( os . path . dirname ( os . path . abspath ( __file__ )), "tmp-cache" )
38- os . makedirs (cls .cache_dir , exist_ok = True )
36+ cls .cache_dir = Path ( __file__ ). parent . joinpath ( "tmp-cache" )
37+ Path . mkdir (cls .cache_dir , parents = True , exist_ok = True )
3938
4039 cls .omc = OMPython .OMCSessionZMQ ()
4140 cls .omc .sendExpression ('setCommandLineOptions("--std=latest")' )
@@ -76,15 +75,15 @@ def test_aixlib_tag_version(self):
7675
7776 # Load package.mo
7877 repopath = self .aixlib_path
79- hits = [os . path . join (repopath , "AixLib" , "package.mo" )]
78+ hits = [str (repopath . joinpath ( "AixLib" , "package.mo" ) )]
8079 self .omc .sendExpression ('loadFile("%s", uses=false)' % hits [0 ])
8180
8281 libentry = new_libentry (
8382 libname = libname ,
8483 tagName = tagName ,
8584 entry = entry ,
8685 hits = hits ,
87- repopath = repopath ,
86+ repopath = str ( repopath ) ,
8887 omc = self .omc
8988 )
9089
@@ -128,7 +127,7 @@ def test_modelica_master_version(self):
128127
129128 # Load package.mo
130129 repopath = self .msl_path
131- hits = [os . path . join (repopath , "Modelica" , "package.mo" )]
130+ hits = [str (repopath . joinpath ( "Modelica" , "package.mo" ) )]
132131 self .omc .sendExpression ('clear()' )
133132 self .omc .sendExpression ('loadFile("%s", uses=false)' % hits [0 ])
134133
@@ -137,7 +136,7 @@ def test_modelica_master_version(self):
137136 tagName = branch ,
138137 entry = entry ,
139138 hits = hits ,
140- repopath = repopath ,
139+ repopath = str ( repopath ) ,
141140 omc = self .omc
142141 )
143142
0 commit comments