from__future__importdivision,print_function,absolute_importimportsysfromscipy._lib._testutilsimport_parse_size,_get_mem_availableimportpytestdeftest__parse_size():expected={'12':12e6,'12 b':12,'12k':12e3,' 12 M ':12e6,' 12 G ':12e9,' 12Tb ':12e12,'12 Mib ':12*1024.0**2,'12Tib':12*1024.0**4,}forinp,outpinsorted(expected.items()):ifoutpisNone:withpytest.raises(ValueError):_parse_size(inp)else:assert_parse_size(inp)==outpdeftest__mem_available():# May return None on non-Linux platformsavailable=_get_mem_available()ifsys.platform.startswith('linux'):assertavailable>=0else:assertavailableisNoneoravailable>=0