Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class UserCodeParser(object):
]

def get_code_to_run(self, code):
code = code.lstrip()
try:
all_but_first_line = code.split(None, 1)[1]
except IndexError:
Expand Down
9 changes: 9 additions & 0 deletions sparkmagic/sparkmagic/tests/test_usercodeparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ def test_other_line_magic():

assert cell == parser.get_code_to_run(cell)

def test_leading_whitespace_magic():
parser = UserCodeParser()
cell = """\n%magic
hi
hi
hi"""

assert cell.lstrip() == parser.get_code_to_run(cell)


def test_scala_code():
parser = UserCodeParser()
Expand Down