Skip to content

Commit

Permalink
other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgen-lentz committed Jan 31, 2025
1 parent fac6fdd commit 7192190
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 3 additions & 1 deletion amplpy/iterators.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ cdef class EnvIterator(object):
return self

def __next__(self):
if self.iterator >= self.end:
cdef int equal
campl.AMPL_EnvironmentFindEnvironmentEqual(self.iterator, self.end, &equal)
if equal:
raise StopIteration
cdef campl.AMPL_ENVIRONMENTITERATOR* it = self.iterator
campl.AMPL_EnvironmentGetEnvironmentVarIterate(self.env_c, &it)
Expand Down
9 changes: 3 additions & 6 deletions amplpy/tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,16 @@ def test_environment_initialization(self):
self.assertEqual("binary_name_2", env.get_bin_name())

def test_environment(self):
os.environ["USER1"] = "Filipe Brandão"
from amplpy import Environment, AMPL

#os.environ["PYTHONIOENCODING"] = "utf-8"
os.environ["USER1"] = "Filipe Brandão"

env1 = Environment()
env2 = Environment(os.curdir)
self.assertEqual(env2.get_bin_dir(), os.curdir)
env1.set_bin_dir(env2.get_bin_dir())
self.assertEqual(env1.get_bin_dir(), env1.get_bin_dir())
#self.assertEqual(len(dict(env1)), len(list(env1)))
#self.assertEqual(list(sorted(dict(env1).items())), list(sorted(env1)))
self.assertEqual(len(env1["USER1"]), len("Filipe Brandão"))
self.assertEqual(len(dict(env1)), len(list(env1)))
self.assertEqual(list(sorted(dict(env1).items())), list(sorted(env1)))
env1["MyEnvVar"] = "TEST"
self.assertEqual(env1["MyEnvVar"], "TEST")
self.assertEqual(env2["MyEnvVar"], None)
Expand Down

0 comments on commit 7192190

Please sign in to comment.