from subprocess import Popen, PIPE
import json
import platform

# Remove "sys.exit" after feedstock creation when running
# on linux-anvil-cos7-x86_64 image
if platform.system() == "Linux":
    import sys
    sys.exit(0)

if platform.system() == "Windows":
    ext = ".cmd"
else:
    ext = ""

p = Popen(
    ['kaleido' + ext, "plotly", "--disable-gpu"],
    stdout=PIPE, stdin=PIPE, stderr=PIPE,
    text=True
)

stdout_data = p.communicate(
    input=json.dumps({"data": {"data": []}, "format": "png"})
)[0]
assert "iVBORw" in stdout_data

from subprocess import Popen, PIPE
import json
import platform

# Remove "sys.exit" after feedstock creation when running
# on linux-anvil-cos7-x86_64 image
if platform.system() == "Linux":
    import sys
    sys.exit(0)

if platform.system() == "Windows":
    ext = ".cmd"
else:
    ext = ""

p = Popen(
    ['kaleido' + ext, "plotly", "--disable-gpu", "--no-sandbox", "--disable-breakpad"],
    stdout=PIPE, stdin=PIPE, stderr=PIPE,
    text=True
)

stdout_data = p.communicate(
    input=json.dumps({"data": {"data": []}, "format": "png"})
)[0]
assert "iVBORw" in stdout_data

Fix hanging test on MacOS
Fix hanging test on MacOS

  from subprocess import Popen, PIPE
  import json
  import platform
  
  # Remove "sys.exit" after feedstock creation when running
  # on linux-anvil-cos7-x86_64 image
  if platform.system() == "Linux":
      import sys
      sys.exit(0)
  
  if platform.system() == "Windows":
      ext = ".cmd"
  else:
      ext = ""
  
  p = Popen(
-     ['kaleido' + ext, "plotly", "--disable-gpu"],
+     ['kaleido' + ext, "plotly", "--disable-gpu", "--no-sandbox", "--disable-breakpad"],
      stdout=PIPE, stdin=PIPE, stderr=PIPE,
      text=True
  )
  
  stdout_data = p.communicate(
      input=json.dumps({"data": {"data": []}, "format": "png"})
  )[0]
  assert "iVBORw" in stdout_data
  
Fix hanging test on MacOS
## Code Before:
from subprocess import Popen, PIPE
import json
import platform

# Remove "sys.exit" after feedstock creation when running
# on linux-anvil-cos7-x86_64 image
if platform.system() == "Linux":
    import sys
    sys.exit(0)

if platform.system() == "Windows":
    ext = ".cmd"
else:
    ext = ""

p = Popen(
    ['kaleido' + ext, "plotly", "--disable-gpu"],
    stdout=PIPE, stdin=PIPE, stderr=PIPE,
    text=True
)

stdout_data = p.communicate(
    input=json.dumps({"data": {"data": []}, "format": "png"})
)[0]
assert "iVBORw" in stdout_data

## Instruction:
Fix hanging test on MacOS
## Code After:
from subprocess import Popen, PIPE
import json
import platform

# Remove "sys.exit" after feedstock creation when running
# on linux-anvil-cos7-x86_64 image
if platform.system() == "Linux":
    import sys
    sys.exit(0)

if platform.system() == "Windows":
    ext = ".cmd"
else:
    ext = ""

p = Popen(
    ['kaleido' + ext, "plotly", "--disable-gpu", "--no-sandbox", "--disable-breakpad"],
    stdout=PIPE, stdin=PIPE, stderr=PIPE,
    text=True
)

stdout_data = p.communicate(
    input=json.dumps({"data": {"data": []}, "format": "png"})
)[0]
assert "iVBORw" in stdout_data
