File tree Expand file tree Collapse file tree 6 files changed +42
-29
lines changed
Expand file tree Collapse file tree 6 files changed +42
-29
lines changed Original file line number Diff line number Diff line change 77
88import scyjava
99
10+ from assertpy import assert_that
11+
1012if platform .system () == "Darwin" :
1113 # NB: This test would hang on macOS, due to AWT threading issues.
1214 sys .exit (0 )
1315
14- assert not scyjava .jvm_started ()
16+ assert_that (scyjava .jvm_started ()).is_false ()
17+
1518scyjava .start_jvm ()
1619
1720if scyjava .is_jvm_headless ():
2124 # In that case, we are not able to perform this test.
2225 sys .exit (0 )
2326
24- assert not scyjava .is_awt_initialized ()
27+ assert_that ( scyjava .is_awt_initialized ()). is_false ()
2528
2629Frame = scyjava .jimport ("java.awt.Frame" )
2730f = Frame ()
2831
29- assert scyjava .is_awt_initialized ()
32+ assert_that ( scyjava .is_awt_initialized ()). is_true ()
Original file line number Diff line number Diff line change 44
55import scyjava
66
7+ from assertpy import assert_that
8+
79scyjava .config .enable_headless_mode ()
810
9- assert not scyjava .jvm_started ()
11+ assert_that ( scyjava .jvm_started ()). is_false ()
1012scyjava .start_jvm ()
11-
12- assert scyjava .is_jvm_headless ()
13+ assert_that (scyjava .is_jvm_headless ()).is_true ()
1314
1415Frame = scyjava .jimport ("java.awt.Frame" )
15- try :
16- f = Frame ()
17- assert False , "HeadlessException should have occurred"
18- except Exception as e :
19- assert "java.awt.HeadlessException" == str (e )
16+ assert_that (Frame ).raises (Exception ).when_called_with ().is_equal_to (
17+ "java.awt.HeadlessException"
18+ )
Original file line number Diff line number Diff line change 22Test scyjava JVM memory-related functions.
33"""
44
5- from assertpy import assert_that
6-
75import scyjava
86
7+ from assertpy import assert_that
8+
99mb_initial = 50 # initial MB of memory to snarf up
1010mb_tolerance = 10 # ceiling of expected MB in use
1111
1212scyjava .config .set_heap_min (mb = mb_initial )
1313scyjava .config .set_heap_max (gb = 1 )
1414
15- assert not scyjava .jvm_started ()
15+ assert_that (scyjava .jvm_started ()).is_false ()
16+
1617scyjava .start_jvm ()
1718
18- assert scyjava .available_processors () >= 1
19+ assert_that ( scyjava .available_processors ()). is_greater_than_or_equal_to ( 1 )
1920
2021mb_max = scyjava .memory_max () // 1024 // 1024
2122mb_total = scyjava .memory_total () // 1024 // 1024
Original file line number Diff line number Diff line change 44
55import scyjava
66
7- assert not scyjava .jvm_started ()
7+ from assertpy import assert_that
8+
9+ assert_that (scyjava .jvm_started ()).is_false ()
810
911before_version = scyjava .jvm_version ()
10- assert before_version is not None
11- assert len (before_version ) >= 3
12- assert before_version [0 ] > 0
12+ assert_that ( before_version ). is_not_none ()
13+ assert_that ( len (before_version )). is_greater_than_or_equal_to ( 3 )
14+ assert_that ( before_version [0 ]). is_greater_than ( 0 )
1315
1416scyjava .config .enable_headless_mode ()
1517scyjava .start_jvm ()
1618
1719after_version = scyjava .jvm_version ()
18- assert after_version is not None
19- assert len (after_version ) >= 3
20- assert after_version [0 ] > 0
20+ assert_that ( after_version ). is_not_none ()
21+ assert_that ( len (after_version )). is_greater_than_or_equal_to ( 3 )
22+ assert_that ( after_version [0 ]). is_greater_than ( 0 )
2123
22- assert before_version == after_version
24+ assert_that ( before_version ). is_equal_to ( after_version )
Original file line number Diff line number Diff line change 66
77import scyjava
88
9+ from assertpy import assert_that
10+
911scyjava .config .endpoints .extend (
1012 ["org.scijava:scijava-common:2.94.2" , "org.scijava:scripting-python:MANAGED" ]
1113)
2325# Assert that the Python script language is available.
2426ss = ctx .service ("org.scijava.script.ScriptService" )
2527lang = ss .getLanguageByName ("Python" )
26- assert lang is not None and "Python" in lang .getNames ()
28+ assert_that (lang ).is_not_none ()
29+ assert_that (lang .getNames ()).contains ("Python" )
2730
2831# Construct a script.
2932script = """
@@ -58,5 +61,5 @@ def calculate_cbrt(age):
5861 sys .stderr .write (f"{ trace } \n " )
5962 raise e
6063
61- assert statement == "2"
62- assert return_value == "The rounded cube root of my age is 2"
64+ assert_that ( statement ). is_equal_to ( "2" )
65+ assert_that ( return_value ). is_equal_to ( "The rounded cube root of my age is 2" )
Original file line number Diff line number Diff line change 99
1010import scyjava
1111
12+ from assertpy import assert_that
13+
1214scyjava .config .endpoints .extend (
1315 ["org.scijava:scijava-common:2.94.2" , "org.scijava:scripting-python:MANAGED" ]
1416)
2628# Assert that the Python script language is available.
2729ss = ctx .service ("org.scijava.script.ScriptService" )
2830lang = ss .getLanguageByName ("Python" )
29- assert lang is not None and "Python" in lang .getNames ()
31+ assert_that (lang ).is_not_none ()
32+ assert_that (lang .getNames ()).contains ("Python" )
3033
3134# Construct a script.
3235script = """
5558 sys .stderr .write (f"{ trace } \n " )
5659 raise e
5760
58- assert statement == "Hello, Chuckles! In one year you will be 14 years old."
59- assert return_value == "A wild return value appears!"
61+ assert_that (statement ).is_equal_to (
62+ "Hello, Chuckles! In one year you will be 14 years old."
63+ )
64+ assert_that (return_value ).is_equal_to ("A wild return value appears!" )
You can’t perform that action at this time.
0 commit comments