code: def test_issue_11():
      # https://github.com/syrusakbary/promise/issues/11
      def test(x):
          def my(resolve, reject):
              if x > 0:
                  resolve(x)
              else:
                  reject(Exception(x))
  
          return Promise(my)
  
      promise_resolved = test(42).then(lambda x: x)
      assert promise_resolved.get() == 42
  
      promise_rejected = test(-42).then(lambda x: x, lambda e: str(e))
      assert promise_rejected.get() == "-42"
  
file_path: wandb/wandb/vendor/promise-2.3.0/tests/test_issues.py
imports: from concurrent.futures import ThreadPoolExecutor
  from promise import Promise
  import time
  import weakref
  import gc
label_desc: Use image node_id 1 for calling a global function with example usage: test_issue_11() and returns: Promise